Hello guys!
I am starting my work with LPC2106. I made some leds flashing, now I am trying
to understand how interrupts works. I could not find any documentation
explining how to implement it using gcc, I have the Insiders Guide, but the
examples are for the Keil only.
I made the program below, but the interrupt function are never called.
Can someone point my error? Or better, where can I get a documentation
explaining how to implement interrupts with gcc?
Thanx in advance for any help.
My code:
In the ex_lpc_lib1.h, the variables are defined as below:
#define GPIO_IODIR (*(t_reg32*)(0xE0028008))
#define PCB_PINSEL0 (*(t_reg32*)(0xE002C000))
#define VICIntSelect (*(t_reg32*)(0xFFFFF00C))
#define VICIntEnable (*(t_reg32*)(0xFFFFF010))
#define SCB_EXTINT (*(t_reg32*)(0xE01FC140))
The program runs by flashing leds attached to pins P0.4 to P0.7 and P010 to
P0.13. The DEBUGF is a macro that sends the string over JTAG. Pressing the
button attached to EINT1 (this pin have a pull up resistor and the switch
pulls the pin down) never go to the interrupcao() routine.
To compile this code, I had to make it as ARM, when I compiled it as THUMB I
got an error saying that the FIQ routine must be compiled as ARM, so I
compiled the entire code as ARM. Is it possible to tell to gcc that I want
only the FIQ routine compiled as ARM?
#include "ex_lpc_lib1.h"
#define DEBUG_LEDS 0
#define DEBUG_OUT 1
#include "ex_debug.h"
static void delay(t_u32 wDelay);
static void escreve(t_u32 valor);
static void interrupcao() __attribute__ ((interrupt("FIQ"))) ;
/*------------------------------------------------------------------------------
main
------------------------------------------------------------------------------*/
int main(void) {
t_u32 escrita = 0x00000010;
t_u32 x;
GPIO_IODIR = 0x00003CF0;
PCB_PINSEL0 = 0x20000000;
VICIntSelect = 0x00008000;
VICIntEnable = 0x00008000;
for(;;) {
for(x=4; x!=0; x--) {
escreve(escrita);
escrita = escrita << 1;
}
escrita = escrita << 2;
for(x=3; x!=0; x--) {
escreve(escrita);
escrita = escrita << 1;
}
for(x=4; x!=0; x--) {
escreve(escrita);
escrita = escrita >> 1;
}
escrita = escrita >> 2;
for(x=3; x!=0; x--) {
escreve(escrita);
escrita = escrita >> 1;
}
}
return 0;
}
void escreve(t_u32 valor) {
// DEBUGF("Valor=%x\n", valor);
GPIO_IOSET = valor;
delay(100);
GPIO_IOCLR = valor;
}
void delay(t_u32 wDelay) {
t_u32 wClock;
// Gets current clock value and programs timer 0 to count in 1milisecond units
wClock = ex_clock_get() * EX_BOARD_MCLOCK;
T0_PR = (wClock / 1000) - 1; // Prescale register
T0_PC = 0; // Prescale counter
T0_TC = 0; // Initialize timer counter
T0_TCR = 1; // Enable counter
// Waits for counter value to reach specified value
while (T0_TC < wDelay)
;
}
void __attribute__ ((interrupt("FIQ"))) interrupcao(void) {
DEBUGF("Interrompido\n");
GPIO_IOSET = 0x00000010;
SCB_EXTINT = 0x00000002;
}Message
Playing with interrupts
2006-01-11 by Xtian Xultz
Attachments
- No local attachments were found for this message.