Hello,
I am programming timer0 using a compare match feature of it, available in Atmega2560 with atmelstuidio7.
I have written the following code, after studying the datasheet, but it's resetting the timer on overflow rather on compare match. Need your assistance regarding this.
Here's the code.
One more thing, I am checking comparison b/w TCNT0 register & OCR0A using simulator mode in atmelstudio7.
I am programming timer0 using a compare match feature of it, available in Atmega2560 with atmelstuidio7.
I have written the following code, after studying the datasheet, but it's resetting the timer on overflow rather on compare match. Need your assistance regarding this.
Here's the code.
C:
#include <avr/io.h>
void delaynew ();
int main(void)
{
DDRB = 0xFF; //PortB is set as o/p
while (1)
{
PORTB = 0xAA;
delaynew();
PORTB = 0x55;
delaynew();
}
}
void delaynew (void)
{
TCCR0A =0xC0;
//TCNT0 = 0x00; //Initialized the counter
OCR0A = 0xA0; //Set the delay to 50 a/c to decimal
TCCR0B = 0x01; //set the clock with no prescale
while ((TIFR0 & 0b00000011) == 0b00000011)
{
TCCR0B = 0x00;
TIFR0 = 0x03;
}
}
Last edited by a moderator: