raja.afiq
Newbie level 3
i using pic18f4550. i made a coding as salve to run a servo motor. i try to make a delay using TMR0.
this is one of my code for delay
i define freq as 20Mhz
the problem is why the TMR0ON=1; in the coding have error: expression syntax. because i use the same coding for other program and it work. TMR0H in that program i use actual value in hexa.
this is one of my code for delay
i define freq as 20Mhz
Code:
void delay_tanda1 (void){
w=1850; //i using this because w will be variable that come from master
T0CON=0b01001000; // 8bit timer, prescaler 1:64
TMR0H = 256-((w*freq)/(256))
TMR0ON = 1; // Turn On Timer0
while (TMR0IF==0); // wait until overflow
TMR0ON = 0; // Turn off timer 0
TMR0IF = 0; // Reset timer0 flaq
}