elcielo
Full Member level 6
timer0_ovf_vect
unsigned int g_usec;
void TimerInit(void)
{
TCCR0 = 0x00; //stop
ASSR = 0x00; //set async mode
TCNT0 = 0xC6; //set count
OCR0 = 0x3A;
TCCR0 = 0x01; //start timer
TIMSK = 0x01;
}
void delay(unsigned int us)
{
g_usec = 0;
if (us>0) while(g_usec<us){;}
}
#pragma vector = TIMER0_OVF_vect
__interrupt void TIMER0_OVF_interrupt (void)
{
TCNT0 = 0xC6; //reload counter value
g_usec++;// 1 uSec/one
}
void main(void)
{
delay(255); <-operate
delay(10000); <-didn't oprate
}
Didn't operat...
How I do check option ?
Atmega 128
unsigned int g_usec;
void TimerInit(void)
{
TCCR0 = 0x00; //stop
ASSR = 0x00; //set async mode
TCNT0 = 0xC6; //set count
OCR0 = 0x3A;
TCCR0 = 0x01; //start timer
TIMSK = 0x01;
}
void delay(unsigned int us)
{
g_usec = 0;
if (us>0) while(g_usec<us){;}
}
#pragma vector = TIMER0_OVF_vect
__interrupt void TIMER0_OVF_interrupt (void)
{
TCNT0 = 0xC6; //reload counter value
g_usec++;// 1 uSec/one
}
void main(void)
{
delay(255); <-operate
delay(10000); <-didn't oprate
}
Didn't operat...
How I do check option ?
Atmega 128