Hi, I am sorry if there is already a thread open with this problem, I just couldn't find it.
I have a problem which should be easy to solve for you guys. I am trying to get a simple interrupt service routine to run, when i press the INT0 button on a MCB2300 Board (LPC2368). I didn't chance the startup.s code at all. When I press the button, nothing happens. Please help me.
#include <LPC23xx.h> int main(void) { PINSEL10 = 0; FIO2DIR = 0x000000FF; FIO2MASK = 0x00000000; FIO2CLR = 0xFF; FIO2SET = 0x55; VICIntSelect = 0x00008000; VICIntEnable = 0x00008000; while(1){ } return 0; } int i; void __irq FIQ_Handler (void) { FIO2DIR = 0x000000FF; FIO2MASK = 0x00000000; //Here goes the interrupt for ( i = 0; i <10000; i++) { FIO2CLR = 0xFF; FIO2SET = 0xAA; } FIO2CLR = 0xFF; VICVectAddr = 0x00000000; }
Hi, I tried to change the code but it didn't work. So I looked around a bit and tried to find a solution but all I found didn't work.
I now use code I found on the internet and changed a bit but still, nothing.
I know my code wasn't exactly what one would call beautiful, it was just for testing, nothing to keep for later.
So can anyone tell me whats wrong here?
#include <stdio.h> #include <LPC23xx.H> void initialize_leds (void) { FIO2DIR = 0x000000FF; // Define P2.0 through P2.7 as Outputs FIO2MASK = 0x00000000; } void set_led(unsigned int value) { FIO2CLR = 0xFF; FIO2SET = (value & 0xFF); } volatile int led_state = 0; void isr_handler_eint0(void) __irq // for external interrupt 0 { VICIntEnClr = (1 << 14); // Disable EINT0 in the VIC //this causes the leds to light up in sequence led_state = ( led_state << 1 ) | 1; //if all leds are lit up, turn them all off if( led_state > 0xFF) led_state = 0; set_led(led_state); //EXTPOLAR = 1; // next interrupt on rising edge EXTINT = 0x01; // Clear the peripheral interrupt flag VICIntEnable = (1 << 14); // Enable EINT0 in the VIC VICVectAddr = 0; // Acknowledge Interrupt } void initialize_eint0 (void) { // P2.10 as EINT0 interrupt (push button on MCB2300) PINSEL4 |= 0x01 << 20; // EINT0 is (falling) edge-sensitive EXTMODE = 0x01; // assign our ISR handler function to this VIC address VICVectAddr14 = (unsigned) isr_handler_eint0; // Interrupt on the falling edge (should default to 0) EXTPOLAR = 0x00; // Clear the peripheral interrupt flag EXTINT = 0x01; // Enable EINT0 VICIntEnable = (1 << 14); } __inline void enable_IRQ(void) { int tmp; __asm { MRS tmp, CPSR BIC tmp, tmp, #0x80 MSR CPSR_c, tmp } } __inline void enable_FIQ(void) { int tmp; __asm { MRS tmp, CPSR BIC tmp, tmp, #0x40 MSR CPSR_c, tmp } } int main (void) { enable_IRQ(); enable_FIQ(); PINSEL10 = 0; // Disable ETM interface initialize_leds(); // Init LEDS initialize_eint0(); // Init EINT0 while (1) { // ... do nothing } }