Issue with LPC2132FBD64: unable to get fiq to work.
My main program calls TIMER1_Init() and I get kicked into the prefetch_abort_irq().
I have also tried the vectored irq method (not shown but the changes are minimal) and I get kicked into the software_irq().
If the timer is not enabled to interrupt on match the processor (T1MCR_MR0I) the while loop displays the timer counter register. I know it is counting correctly.
I have worked with the lpc2148 and lpc1768 with no problems. I was wondering if the notations in the manual about the LPC2132/01 being a upgrade to the LPC2132 would matter. It looks like the date code on my LPC2132 is "07".
-------------------------------------------------------------------------------------
_start:
b reset /* reset */
b undef_instruction_irq /* undefined instruction */
b software_irq /* software interrupt */
b prefetch_abort_irq /* prefetch abort */
b data_abort_irq /* data abort */
nop /* reserved for the bootloader checksum */
ldr pc, [pc, #-0x0ff0] /* IRQ */
b fiq_irq /* FIQ */
-------------------------------------------------------------------------------------
#define T1IR_MR0_INTERRUPT 0x01
void fiq_irq(void)
{
timer1_ticks++;
T1IR = T1IR_MR0_INTERRUPT;
}
-------------------------------------------------------------------------------------
void software_irq(void)
{
LED_Blink(0x02);
}
-------------------------------------------------------------------------------------
void prefetch_abort_irq(void)
{
LED_Blink(0x03);
}
-------------------------------------------------------------------------------------
#define MEMMAP_MAP_INT_VECTORS_IN_FLASH 0x01
void MEMMAP_Init(void)
{
MEMMAP = MEMMAP_MAP_INT_VECTORS_IN_FLASH;
}
-------------------------------------------------------------------------------------
#define SCS_GPIO0M_HIGH_SPEED 0x00000001
#define SCS_GPIO1M_HIGH_SPEED 0x00000002
void GPIO_Init(void)
{
/* Enable high speed GPIO on port 0 & 1 */
SCS = SCS_GPIO1M_HIGH_SPEED | SCS_GPIO0M_HIGH_SPEED;
}
-------------------------------------------------------------------------------------
void LED_Write(uint8_t num)
{
FIO0PIN0 = ~num;
}
void LED_Blink(uint8_t num)
{
while(1)
{
LED_Write(num);
delay(250);
LED_Write(0);
delay(250);
}
}
void LED_Init(void)
{
FIO0DIR0 = 0xFF;
FIO0SET0 = 0xFF;
}
-------------------------------------------------------------------------------------
#define REG8(x) (*((volatile uint8_t*) (x)))
#define REG16(x) (*((volatile uint16_t*) (x)))
#define REG32(x) (*((volatile uint32_t*) (x)))
#define PCONP_PCTIM1 0x00000004
#define CCLK 60000000
#define TIMER1_RATE 100
#define T1CTCR_MODE_TIMER 0x00
#define T1MCR_MR0I 0x0001
#define T1MCR_MR0R 0x0002
#define VICIntSelect_TIMER1 0x00000020
#define T1TCR_COUNTER_ENABLE 0x01
#define T1TC REG32(0xE0008008)
#define T1PR REG32(0xE000800C)
#define T1PC REG32(0xE0008010)
#define T1MCR REG16(0xE0008014)
#define T1MR0 REG32(0xE0008018)
#define T1CTCR REG8(0xE0008070)
#define VICIntSelect REG32(0xFFFFF00C)
void TIMER1_Init(void)
{
/* Turn on power to timer */
PCONP |= PCONP_PCTIM1;
/* Clear counters */
T1PR = 0;
T1PC = 0;
T1MR0 = CCLK / TIMER1_RATE;
T1CTCR = T1CTCR_MODE_TIMER; /* timer mode */
T1MCR = T1MCR_MR0I | T1MCR_MR0R; /* interrupt on match */
VICIntSelect |= VICIntSelect_TIMER1; /* FIRQ category */
T1TCR = T1TCR_COUNTER_ENABLE; /* enable for counting */
}
-------------------------------------------------------------------------------------
int main(void)
{
uint8_t count;
MEMMAP_Init();
GPIO_Init();
LED_Init();
TIMER1_Init();
while (1)
{
for (count = 0; count < 0x100; count++)
{
LED_Write(T1TC);
delay(100);
}
}
}
Got it solved. Modified Makefile so that fiq_irq is not compiled with "-mthumb -mthumb-interwork".
Hi Sudjian,
Thanks for sharing your solution with the Community!
Best regards!
/Carlos