May 27, 2013 #1 C cipi-cips Member level 4 Joined Jun 30, 2008 Messages 76 Helped 2 Reputation 4 Reaction score 1 Trophy points 1,288 Activity points 1,867 hello Is it possible to compare value with timer in c18 compiler, if yes can you show me how for example I have variable that change from 1000-2000 and i have timer where interrupt occurs every 20ms while (my_variable <= timer) { do something } thx
hello Is it possible to compare value with timer in c18 compiler, if yes can you show me how for example I have variable that change from 1000-2000 and i have timer where interrupt occurs every 20ms while (my_variable <= timer) { do something } thx
May 28, 2013 #2 jayanth.devarayanadurga Banned Joined Dec 4, 2012 Messages 4,280 Helped 822 Reputation 1,654 Reaction score 791 Trophy points 1,393 Location Bangalore, India Activity points 0 Code C - [expand]1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 void interrupt(){ if(INTCON.TMR0IF){ INTCON.TMR0IF = 0; TMR0H = x; TMR0L = y; timer++; } } void main(){ //Initialize and start Timer0 here while(1){ if(my_variable <= timer){ } } }
Code C - [expand]1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 void interrupt(){ if(INTCON.TMR0IF){ INTCON.TMR0IF = 0; TMR0H = x; TMR0L = y; timer++; } } void main(){ //Initialize and start Timer0 here while(1){ if(my_variable <= timer){ } } }