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.

problem in pic18f timer 0 interrupt in Micro C compiler ?

Status
Not open for further replies.

haroon_tech

Member level 2
Joined
Apr 28, 2011
Messages
51
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
bangalore
Activity points
1,727
hi,
the code i have written to handle timer0 interrupt .but isr is not executing ......what is problem in my code .the compile is Micro C compiler



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
29
30
31
32
33
34
35
36
37
38
39
40
void timer_init(void);
 
void interrupt (void)
 
{
    INTCON.TMR0IF=0;
    
    TMR0L=0X00;
    INTCON.TMR0IE=1;
    T0CON.TMR0ON=1;
 
}
  main()
  {
        timer_init();
        
        while(1);
        
   }
 
 
 
void timer_init(void)
{
INTCON.GIE=1;              //globle interrupt enable
INTCON.PEIE=1;               //peripharel interrupt enable
INTCON.TMR0IF=0;            //clear the timer0 flag
TMR0L=0x00;           //timer0 reg with initial count
//prescalar value 1:256
T0CON.T0PS0=0;
T0CON.T0PS1=0;
T0CON.T0PS2=0;
 
T0CON.PSA=0;             //prescaler is assigned to timer0
//T0SE=0;
T0CON.T0CS=0;
T0CON.T08BIT=1;         //use internal clock or timer mode
INTCON.TMR0IE=1;          //enable the timer0 by setting TRM0IE flag
T0CON.TMR0ON=1;
}

 
Last edited by a moderator:

Do the following changes in your ISR

Code:
void interrupt()
{
TMR0L = 0x00;
INTCON.TMR0IF = 0;
}

Hope this works
 

How did you deduce that the ISR isn't executing? Are you using the debugger in mikroC? There you can't test the interrupt directly. To do that you need to click the go/jump to interrupt button.

Hope this helps.
Tahmid.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top