Teja.p
Member level 2
pic timer 0 , tiimer delay is not working
i am using pic16f73 and timer0 and clock frequency 8MHZ
of prescaler 1:16
by using formula
vaule= (required delay* fosc/4*prescaler
for 1ms delay
value =125
but it was not working real time.....its output delay coming around 25micro se
please help
how generate 1ms sec delay
i am using pic16f73 and timer0 and clock frequency 8MHZ
of prescaler 1:16
by using formula
vaule= (required delay* fosc/4*prescaler
for 1ms delay
value =125
but it was not working real time.....its output delay coming around 25micro se
Code:
void delay(unsigned int a)
{
unsigned int i=0;
for(i=0;i<a;i++)
{
;
OPTION_REG=0x46;
TMR0IF_bit = 0; // Clear interrupt bit
TMR0IE_bit= 1; // Enable Timer1 interrupt
PEIE_bit= 1; // Enable peripheral interrupts
GIE_bit= 1;
TMR0=125;
;
while(TMR0IF_bit==1) //If Timer1 Interrupt
{
TMR0IF_bit= 0; // clear the interrupt
}
}
}
how generate 1ms sec delay
Last edited by a moderator: