Hi. Can I simulation function void eint1_srv (void) __irq . Can I set intterupt EINT1 in Keil and check this function?
#include <LPC21xx.H>
int volatile intrp_count = 0; void eint1_srv (void) __irq { ++intrp_count; EXTINT= 2; VICVectAddr = 0; }
void init_eint1 (void) { EXTMODE = 2; EXTPOLAR = 2; PINSEL0 = 2 << 28; VICVectAddr0 = (unsigned long) eint1_srv; VICVectCntl0 = 0x20 | 15; VICIntEnable = 1 << 15; }
int main (void) { unsigned int LED_out = 0;
IODIR1 = 0xFF0000;
init_eint1(); while (1) { if ((intrp_count & 0xFF) != LED_out) { LED_out = (intrp_count & 0xFF); IOCLR1 = 0xFF0000; IOSET1 = (LED_out << 16); } } }
Maybe this program doesn't work? Can you check this code?
#include <LPC22xx.H>
void init_eint1 (void) { PINSEL0 = 2 << 28; EXTMODE = 2; EXTPOLAR = 2; EXTINT=0x02 VICVectAddr0 = (unsigned long) eint1_srv; VICVectCntl0 = 0x20 | 15; VICIntEnable = 1 << 15; }
int main (void) { unsigned int LED_out = 0; IODIR1 = 0xFF0000; init_eint1(); while (1) { if ((intrp_count & 0xFF) != LED_out) { LED_out = (intrp_count & 0xFF); IOCLR1 = 0xFF0000; IOSET1 = (LED_out << 16); } } }