Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Interrupt

Status
Not open for further replies.

GammaRay86

New Member
Hello,

I'm having trouble running an interrupt on a PIC. I'm using the CC5X compiler and it says it requires that the interrupt is placed in codepage 0, address 4. It gives this following sample code:

Code:
#include "int16CXX.h"

#pragma origin 4

interrupt serverX(void)
{

int_save_registers // W, STATUS (and PCLATH)

//char sv_FSR = FSR; // if required

// handle the interrupt

//FSR = sv_FSR; // if required

int_restore_registers // W, STATUS (and PCLATH)
}

The problem is if I do put the interrupt at the top of the code, before setting any variables, then obviously the variables I use in the interrupt do not work. These variables are used in the main function as well. If I define the variables first, it will not compile because it complains that the interrupt service is not placed on address 4.

There is also a #pragma unlockISR that will allow the program to compile regardless of where the interrupt is placed but the code does not work as intended. The CC5X manual says "The following pragma statement will allow the interrupt routine to be placed anywhere. Note that the compiler will NOT generate the link from address 4 to the interrupt routine."

#pragma unlockISR

Specifically, if the interrupt service routine isn't placed where they want it, the compiler gives this error:
"Wrong start address for interrupt service routine (The interrupt service routine must normally be the first function on codepage 0, located at address 4)"

If I place the interrupt service routine at the end of the code and just above it put "#pragma origin 4" the compiler gives this error:

"Overlapping code (The pointer to the next free location in each code page can not be moved backwards (only forwards). This also applies if locations was skipped by an earlier #pragma origin statement)"

What does that exactly mean? Can anyone help? I have not been able to find a solution. Thanks a lot.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top