Skip to main content
Tweeted twitter.com/StackArduino/status/1344795536197627904
added 356 characters in body
Source Link

When I am in the 30-second standby function, I want to turn the LED on and off at 5-second intervals.

How can I do what I want using the read_counter() function?

The problem here is that I am already in the timer function with the read_counter() function.

void wait_function() {
  timer_init();
  while(read_counter()<30000) { //30 second wait
    // A LED blinking at 1 second intervals ???
  }
}

Note: The read_counter() function increases every 1 millisecond with ISR COMPA vector. I tried many times and couldn't find a stable solution. Example:

if (read_counter() % 1000) PORTB^=(1<<LED);

Update: My new code :

while((TIFR1 & (1 << OCF1A))==0) //4secondIf I do this cycle 8 times, it 
                                 //makes 32 seconds.
            {
                if(TCNT1%15624==0) //per 15624=1 second,
                PORTA^=(1<<0);
                 //led_blink_1s
            }

But,it doesn't work.Should I use util delay function?

When I am in the 30-second standby function, I want to turn the LED on and off at 5-second intervals.

How can I do what I want using the read_counter() function?

The problem here is that I am already in the timer function with the read_counter() function.

void wait_function() {
  timer_init();
  while(read_counter()<30000) { //30 second wait
    // A LED blinking at 1 second intervals ???
  }
}

Note: The read_counter() function increases every 1 millisecond with ISR COMPA vector. I tried many times and couldn't find a stable solution. Example:

if (read_counter() % 1000) PORTB^=(1<<LED);

When I am in the 30-second standby function, I want to turn the LED on and off at 5-second intervals.

How can I do what I want using the read_counter() function?

The problem here is that I am already in the timer function with the read_counter() function.

void wait_function() {
  timer_init();
  while(read_counter()<30000) { //30 second wait
    // A LED blinking at 1 second intervals ???
  }
}

Note: The read_counter() function increases every 1 millisecond with ISR COMPA vector. I tried many times and couldn't find a stable solution. Example:

if (read_counter() % 1000) PORTB^=(1<<LED);

Update: My new code :

while((TIFR1 & (1 << OCF1A))==0) //4secondIf I do this cycle 8 times, it 
                                 //makes 32 seconds.
            {
                if(TCNT1%15624==0) //per 15624=1 second,
                PORTA^=(1<<0);
                 //led_blink_1s
            }

But,it doesn't work.Should I use util delay function?

Formatted code, editorial changes.
Source Link
ocrdu
  • 1.8k
  • 3
  • 12
  • 24

How can I control blinking of ledLED while in timer function?

When I am in the 30-second standby function, I want to turn the LED on and off at 5-second intervals. .How

How can I do what I want using the again read_counter()read_counter() function? The

The problem here is that I am already in the timer function with the read_counterread_counter() function.

void wait_function() {
  timer_init();
  while(read_counter()<30000) { //30 second wait
    // A LED blinking at 1 second intervals ???
  }
}

Note:The The read_counter() function increases every 1 millisecond with ISR COMPA vector.I I tried many times and couldn't find a stable solution.Example,as if(read_counter()%1000) PORTB^=(1<<LED) Example:

void wait_function()
    {

      timer_init();
      while(read_counter()<30000) //30 second wait 
      {

                                  //A LED blinking at 1 second intervals ???
       
      }

    
    }

if (read_counter() % 1000) PORTB^=(1<<LED);

How can I control blinking of led while in timer function?

When I am in the 30-second standby function, I want to turn the LED on and off at 5-second intervals. .How can I do what I want using the again read_counter() function? The problem here is that I am already in the timer function with the read_counter function.

Note:The read_counter() function increases every 1 millisecond with ISR COMPA vector.I tried many times and couldn't find a stable solution.Example,as if(read_counter()%1000) PORTB^=(1<<LED)

void wait_function()
    {

      timer_init();
      while(read_counter()<30000) //30 second wait 
      {

                                  //A LED blinking at 1 second intervals ???
       
      }

    
    }

How can I control blinking of LED while in timer function?

When I am in the 30-second standby function, I want to turn the LED on and off at 5-second intervals.

How can I do what I want using the read_counter() function?

The problem here is that I am already in the timer function with the read_counter() function.

void wait_function() {
  timer_init();
  while(read_counter()<30000) { //30 second wait
    // A LED blinking at 1 second intervals ???
  }
}

Note: The read_counter() function increases every 1 millisecond with ISR COMPA vector. I tried many times and couldn't find a stable solution. Example:

if (read_counter() % 1000) PORTB^=(1<<LED);

Source Link

How can I control blinking of led while in timer function?

When I am in the 30-second standby function, I want to turn the LED on and off at 5-second intervals. .How can I do what I want using the again read_counter() function? The problem here is that I am already in the timer function with the read_counter function.

Note:The read_counter() function increases every 1 millisecond with ISR COMPA vector.I tried many times and couldn't find a stable solution.Example,as if(read_counter()%1000) PORTB^=(1<<LED)

void wait_function()
    {

      timer_init();
      while(read_counter()<30000) //30 second wait 
      {

                                  //A LED blinking at 1 second intervals ???
       
      }

    
    }