timers in mplab question

Status
Not open for further replies.

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
 


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){
 
        }
    }
}

 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…