Hi,
I'm kind of new to programming MCUs but this must be something I missed when I was reading about them. I am programming a MC68HC098QY4 motorola processor with CodeWarrior and in C Language. Everything was going fine until I discovered that after my software sets off a keyboard interrupt, the chip resets itself. WHYYY??? Here's what I'm doing.
from the start of the main function:
-configure registars
-go into stop mode and wait for keyboard interrupt
-when interrupt comes in, blink a LED a few times then acknoledge interrupt and clear interrupt masks (asm CLI).
now turns out, the program restarts when it comes out of the interrupt! is this supposed to happen? how can i prevent it? I even tried finding out what's setting offf the reset using the SRSR register but no lock! I've enclosed my code for your review. any help would be greatly appreciated.
thanks in advance, Aria
********** CODE: **********#include /* for EnableInterrupts macro */ #include /* include peripheral declarations */ #include
#define EVER (;;)
void lightOn(int num); void lightOff(int num); void blink(int num);
int i; byte cyc; int adrval; int zeroadr;
void main(void) { //EnableInterrupts; /* enable interrupts. Same as CLI command */ /* include your code here */
//setting CONFIG1 and CONFIG2 CONFIG1 = 0x2B; //00101011 CONFIG2 = 0x01; //00000001
//setting ADSCR ADSCR = 0x23; //00100011 Continous ADC on AD3
//setting ADC clock ADICLK = 0x80; //busclock / 16
//enabling keyboard inputs KBSCR_IMASKK = 1; KBIER = 0x13; //00010011 KBSCR_MODEK = 1; KBSCR_ACKK = 1; KBSCR_IMASKK = 0;
//setting up port B PTB = 0x00; //initializing
DDRB = 0xFF; //all pins on port B configured as outputs
PTB_PTB0 = 0;
//zeroadr = ADR; //ADR value at "zero" load.
blink(3); lightOn(0); for (i=0;i