Unable to understand the code with repect to LED blinking when a timer expires

Discussion in 'Embedded Systems and Microcontrollers' started by phanideepak007, Apr 26, 2012.

  1. phanideepak007

    Thread Starter New Member

    Oct 28, 2011
    4
    0
    I am working on a Project . I am in a situation where i have to edit code which has no documentation. I am unable to understand a concept which the code claims to be.

    // Prototype code
    // internal clock running at 10MHZ

    #define ERROR1 500 // frequency of the LED flashing on error1 (f=1Hz)
    #define ERROR2 100 // frequency of the LED flashing on error2 (f=5Hz)

    //To turn on millisec timer assign a value and timer will run for specified amount of time

    mtimer failure // declaring failure as a millisectimer .

    if (i==1)
    failure = ERROR1;

    if(i==2)
    failure = ERROR2;

    if(//failure expires)
    {
    blink green led;
    blink red led;

    }

    Q1) Why frequency of LED blinking is given 1HZ and 5 HZ repectively.?
    Q2) How led is able to blink with those frequencies while the code is executed only after timer is expired..?
    q3) what really can happen..??

    Thanks in Advance
     
  2. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    :confused:We will not be able to help unless you provide more info. Start by telling us what controller you are using. And also which compiler you are using. Then post all your code.
     
  3. phanideepak007

    Thread Starter New Member

    Oct 28, 2011
    4
    0
    im sorry,i cannot post the code but i can help you understand . i almost need yes or no kind of answer.. i have less experience in working with mc's so i have less idea on their behavior. The neuron firmware supports many inbuilt functions.one of them is like you can declare a timer as i did above and this name starts the timer for the specified length of time when time is loaded. So when 500 is loaded the timer starts and when it expires the if condition (failure expires)executes but the code claims that when its loaded 500ms it only executed the (failure expires)but also blinks led with 1hz and same when loaded with 100ms but it blinks led with 5hz.. the effect of timer is still there even after its expired ..??? if so, it should be 2hz with 500ms and 10z with 100ms... or what i assumed is wrong..?? thanks for the reply.
     
  4. phanideepak007

    Thread Starter New Member

    Oct 28, 2011
    4
    0
    small correction in line 4 at the end***500ms it not only executes the (failure expires)but also
     
  5. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Sorry, but I have still no idea. What you are talking about. If you can not give a proper description on what you are trying to do. You can expect any help from this forum.
     
  6. phanideepak007

    Thread Starter New Member

    Oct 28, 2011
    4
    0
    thats ok .. no prob..!! thank u
     
Loading...