Interrupts on a PIC18

Ok, I THOUGH I was following the C18 compiler User guide to a T, but I am having trouble getting the interrupts to work right.

I am working with a PICDEM HPC, which has a 18F8722 as the main chip, I am just trying something simple to get an understanding of their interrupt system.

The HPC demo board has 8 LEDs on PortD, the code powers every other LED 1010 1010.

When I don't include the ioA.x files in my project - everything works as expected. When I reset the board, the 4 LEDs come on. But when I compile the code w/ ioA.c and ioA.h as part of the project, then nothing happens. When I reset the board, the LEDs light up.

So:

  1. Is something wrong w/ my code (which does compile BTW)?
  2. Am I expecting the wrong thing to happen?
  3. ???

Stumped, looking for some direction. RonB

//main.c

#include #include "ioA.h" #include "ports.h" #include "RS232_IO.h"

void setup(void) { setupPorts(); RCON = 0x80; IPR1 = 0x20; INTCON = 0x80; }

void main(void) { setup(); while(1){}; }

//------------------------- // ports.c

#include #include "ports.h"

void setupPorts(void) { LATD = 0xAA; TRISD = 0; }

//------------------------- // ports.h

#ifndef PORTS_H #define PORTS_H

void setupPorts(void);

#endif

//------------------------- // ioa.c

#include #include "IOA.H" #include

#pragma code rx_interrupt=0x08 void rx_int(void) { _asm goto rx_handler _endasm } #pragma code

#pragma interrupt rx_handler void rx_handler(void) { PIR1bits.RCIF = 0; } #pragma code

//------------------------- // ioa.c

#ifndef IOA_H #define IOA_H

void rx_handler(void);

#endif

//------------------------- // ioa.h

#ifndef IOA_H #define IOA_H

void rx_handler(void);

#endif

Reply to
Ron Blancarte
Loading thread data ...

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.