I have template class for Uart. For initialization of interrupt I use global function which is defined as extern "C", but my interrupt is never called. I cannot find whats wrong.
/* header file */ extern "C" void USART0_RX_vect (void) __irq; template <int RXBuf, int TXBuf> class Uart { public: 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; } }; /* cpp file */ void USART0_RX_vect (void) __irq { g_Uart->receiverHandler (LPC_UART0); LPC_VIC->VectAddr = 0x0; }
It's been a long time from when I was working on this, but revisiting the project now I still havent found the solution. For some reason my Vect routine is never called. Is there a way to catch which one is called or how to force to call the global one ? I was expecting some kind of exception if vect addr is invalid ..
Frankly the definition is going to be more critical than the prototype, as it is the former that exports...
/* cpp file */ extern "C" void USART0_RX_vect (void) __irq { g_Uart->receiverHandler (LPC_UART0); LPC_VIC->VectAddr = 0x0; }
View all questions in Keil forum