Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

generating a clock using void isr interrupt

Status
Not open for further replies.

winnie mong

Junior Member level 3
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

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top