This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Interrupt vect never called [C++] - Cont.

Continuation of this now locked thread:
http://www.keil.com/forum/61560/

You continued on an older thread that is now auto-locked - a long time bug that Keil just seem to refuse to fix. Why lock _after_ a new post instead of locking _before_???

Anyway - you forgot something _very_ critical in your thread, that makes it hard to help you - you never specified what chip you have.

Important? Yes very! One important difference between different generations of LPCxxxx chips from NXP is the definition of the VecCntlXX registers.

For LPC21xx, the register is used to assign a peripheral device to a specific channel of the VIC. The name of the register - i.e. the used VIC channel - represents the priority.

For LPC23xx, then the register name (the VIC channel) is hard-coded to a specific peripheral, and you instead assign the priority.

If you do have a (now very old) LPC21xx, then your use of the VIC channels seems to be correct.

But if you have a newer LPC chip, then you would have tried to use VIC channel 8 (which the processor maps to PWM1) when UART0 should instead have used VIC channel 6.

void initInterrupt (uint32_t a_baudrate, LPC_UART_TypeDef* a_channel)
{
    init (a_baudrate, a_channel);

    if (a_channel == LPC_UART0) {
        LPC_VIC->IntEnable |= INT_EN_UART0; //enable UART0 int
        LPC_VIC->IntSelect = 0x00000000;
        LPC_VIC->VectCntl8 = IRQ_SLOT_UART0 | IRQ_SLOT_ENABLE;
        LPC_VIC->VectAddr8 = (unsigned long) USART0_RX_vect;
    }
    else if (a_channel == LPC_UART1) {
        LPC_VIC->IntEnable |= INT_EN_UART1; //enable UART1 int
        LPC_VIC->IntSelect = 0x00000000;
        LPC_VIC->VectCntl7 = IRQ_SLOT_UART1 | IRQ_SLOT_ENABLE;
        LPC_VIC->VectAddr7 = (unsigned long) USART1_RX_vect;
    }
    a_channel->IER |= UART_RDA_ENABLE | UART_RX_STAT_ENABLE;
}

A note here is that when Keil added support for LPC23xx, then continued with the register name VectCntXX.
So the header file for LPC23xx did look like:

/* The name convention below is from previous LPC2000 family MCUs, in LPC23xx/24xx,
these registers are known as "VICVectPriority(x)". */
#define VICVectCntl0   (*(volatile unsigned long *)(VIC_BASE_ADDR + 0x200))
#define VICVectCntl1   (*(volatile unsigned long *)(VIC_BASE_ADDR + 0x204))
...
/* LPC23xx/24xx VICVectPriority(x)". */
#define VICVectPriority0   (*(volatile unsigned long *)(VIC_BASE_ADDR + 0x200))
#define VICVectPriority1   (*(volatile unsigned long *)(VIC_BASE_ADDR + 0x204))
...


The bad thing was that code moved from LPC21xx to LPC23xx didn't produce any compilation error despite the totally changed definition of this register, and the need to use completely different VIC channels when porting the code.

Anyway - you can never expect a good answer unless you make sure you formulate a good question - complete with as much relevant information as possible. And the actual chip used is almost always extremely important. And I can't tell if this post will help or not, since I do not know what chip you have.