generating a clock using void isr interrupt

Status
Not open for further replies.

winnie mong

Junior Member level 3
Joined
Sep 8, 2013
Messages
26
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
366
hi guys....
i have an interrupt function from a library i am using and i want to use it to produce a clock for my timer.please have a look at what i tried to produce and kindly provide your assistance by indicating where i could have gone wrong..thanks

here i have the function from the library


Code C - [expand]
1
2
3
4
5
6
7
8
9
interrupt isr(void)
{
    if(T0IF) {
        ++pulses;                               // increment pulses
        T0IF=0;                                 // reset TMR0 flag
        
    }
 
}



my effort in producing the clock

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
extern unsigned char pulses;
{
    sec=0;
    min=0;
    hour=0;
void clock()
{
    stop=pulse+160;
    if(++sec==60){
           min++; }
    if(++min==60){
           hour++; }
    if(++hour==24){
        hour=0; }
}





Code C - [expand]
1
2
3
4
if(++pulses==stop){
    clock();
    stop=++tick=1;
}



using the function in main()

Code C - [expand]
1
2
3
4
5
6
int main()
 
if (tick){
    clock();
    tick=0;
}

 

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…