I'm using the LPC2129 and Keil Tools. The purpose of the code is to interrupt on the receipt of a single byte of data and assign "data" to its value. The interrupt seems to work however "data" isn't the right value. Please help, Thanks.
#include <stdio.h> /* prototype declarations for I/O functions */ #include <lpc21xx.h> /* LPC21xx definitions */ void U1ISR(void) __irq; //Declare UART1 IRQ ISR int data; int main (void) { PINSEL0 = 0x0005800A; // Enable UART1 U1LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */ U1DLL = 8; /* 115200 Baud Rate @ 15MHz VPB Clock */ U1LCR = 0x03; /* DLAB = 0 */ U1IER = 0x1; //Enable the RDA interrupt VICVectAddr0 = (unsigned long)U1ISR; //Set UART1 ISR Vector Address VICVectCntl0 = 0x20 | 7; //Enable Slot, Set Channel 7 VICIntEnable = 0x80; //Enable Int UART1 blah ... blah ... blah while (1) { yada ... yada ... yada } } void U1ISR(void) __irq { U1IIR |= 0x01; /* Clear Interrupt */ data = U1RBR; VICVectAddr = 0x0; /* return from interrupt */ }
Thanks, so you confirm that your small code piece can be switched between ARM and Thumb mode using the Flash-Configure, Flash Tools-C tab,-Use Thumb Mode toggle and it compiles in both modes without problems. Is so, I will try a clean install.
I was wondering about your code, initially at (*1*)VicVectAddr0 gets U1ISR, which makes sense. Then at the end of the interupt (*2*) it gets put back to 0x0. and back to U1ISR addr at (*1*) again. Is this the right thing to do I wonder. I would have thought that the ISR vector can be left alone and something else done to reset the interupt for next time. Am I completely wrong or just not understanding what is happening?
(*1*) VICVectAddr0 = (unsigned long)U1ISR; //Set UART1 ISR Vector Address VICVectCntl0 = 0x20 | 7; //Enable Slot, Set Channel 7 VICIntEnable = 0x80; //Enable Int UART1
void U1ISR(void) __irq { U1IIR |= 0x01; /* Clear Interrupt */ data = U1RBR; (*2*) VICVectAddr = 0x0; /* return from interrupt */