pravin b
Member level 5
- Joined
- May 20, 2012
- Messages
- 85
- Helped
- 2
- Reputation
- 4
- Reaction score
- 1
- Trophy points
- 1,288
- Location
- Mumbai, India
- Activity points
- 2,083
Hello Friends,
I am Programming PIC18f4520 to generate 2500Hz Square wave with timer 1, no prescaler.
However I have achieved this using following piece of code;
but when I change the above code like;
some random value of delay is generated; though according to me both the code are same! So I am expecting same output for both the codes i.e. 0.2mses delay or 2500Hz square wave; which is not happening...why?
Please let me know if I am missing something.
Thanks & Regards,
Pravin
I am Programming PIC18f4520 to generate 2500Hz Square wave with timer 1, no prescaler.
However I have achieved this using following piece of code;
Code:
void delay()
{
T1CON=0x80;
TMR1L=0x0C;
TMR1H=0xFE;
TMR1ON=1;
while(TMR1IF==0);
TMR1ON=0;
TMR1IF=0;
}
but when I change the above code like;
Code:
void delay()
{
T1CON=0x80;
TMR1L=0x0C;
TMR1H=0xFE;
TMR1ON=1;
while(TMR1IF==1)
{
TMR1ON=0;
TMR1IF=0;
}
}
some random value of delay is generated; though according to me both the code are same! So I am expecting same output for both the codes i.e. 0.2mses delay or 2500Hz square wave; which is not happening...why?
Please let me know if I am missing something.
Thanks & Regards,
Pravin