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.

C18 Compiler Interrupts?

Status
Not open for further replies.

Slayerza

Full Member level 5
Joined
Oct 22, 2005
Messages
295
Helped
27
Reputation
54
Reaction score
5
Trophy points
1,298
Location
South Africa
Activity points
3,462
c18 interrupt example

Hi,
Can anyone please explain to me how the interrupt structure of the C18 compiler works? I have enabled high priority interrupts andit works OK. However the moment that i try to enable the low interrupts nothing happens. Why?

Thanks
Slayer
 

c18 interrupt

if use an external interrupt, it does not run because when ext int occurs, high interrep vector is called. Maybe use low int vector for timer isr calling. Also i dont use low int..
 

mcc18 interrupt

kurumahmut said:
if use an external interrupt, it does not run because when ext int occurs, high interrep vector is called. Maybe use low int vector for timer isr calling. Also i dont use low int..

H he he he he he !
interrupts for PIC18Fxxxx is the vector, so there are two vector (two level interrupts) for interrupt. When there is a interrupt do, uC will goto address of the vector, so you must ask which interrupt happen ! (the example for HT-PIC18 but C18 is the same,. . . )
void interrupt MyISR()
{
if(TMR0IF == 1)
{
// The active code here
}
if(ADIF == 1)
{
// The active code here
}
. . . . .

}
 

c18 interrupts

There is an example in the C18 manual.
 

interrupt c18

There are two vector interrupt in C18 Compiler.
- One is at 000018:
#pragma code low_vetor=0x18
void interrupt_at_low_vector(void)
{
_asm GOTO low_isr _endasm
}
#pragma code // Return to default code section

- and the other:
#pragma code high_vetor=0x8
void interrupt_at_high_vector(void)
{
_asm GOTO high_isr _endasm
}
#pragma code // Return to default code section

In each vector, you can devide more detail than. (As same as topic was posted above)

Notice: Excepting Privated Flag for each interrrupt, you'll have to turn on Global Flag Interrupt.
Example code:

INTCONbits.TMR0IE = 1; // Enable Timer0
INTCONbits.INT0IE = 0;
INTCONbits.RBIE = 0;
INTCONbits.TMR0IF = 0;
INTCONbits.INT0IF = 0;
INTCONbits.RBIF = 0;

INTCONbits.PEIE = 1; // Enable Peripheral interrupt
INTCONbits.GIE = 1; // Enble Global interrupt
Nop();
 

can anyone provide a complete example program of interrupt on change interrupt?
or external interrupts?
for c18 compiler?

thank you.
 

can anyone provide a complete example program of interrupt on change interrupt?
or external interrupts?
for c18 compiler?

thank you.


Hmm...."conkhicon" has already given you 80% of the code. Did you try googling for "c18 interrupt sample code". Guess not! Well here you go, "http://ww1.microchip.com/downloads/en/devicedoc/51295e.pdf" [Microchip application note: 51295e.pdf] Example 5
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top