SDK 2.2 Interrupt and UART

Showing results for 
Search instead for 
Did you mean: 

SDK 2.2 Interrupt and UART

Contributor III


i use the SDK2.2 and on my system i have a my library where i use the MK22FX512. I want to use a custom library written by me for control the UART4 with interrupt mode. In the init function i have to set the function that will be point when the interrupt happen. If i have this code:

/* Enable interrupts */
InstallIRQHandler(UART4_RX_TX_IRQn, UART4_RX_TX_IRQHandler);

the system give me some errors during the compile :

../drivers/fsl_common.c:114: undefined reference to `__RAM_VECTOR_TABLE_SIZE_BYTES'
../drivers/fsl_common.c:114: undefined reference to `__VECTOR_RAM'
../drivers/fsl_common.c:114: undefined reference to `__VECTOR_TABLE'

where in fsl_common.c i have

uint32_t InstallIRQHandler(IRQn_Type irq, uint32_t irqHandler)
/* Addresses for VECTOR_TABLE and VECTOR_RAM come from the linker file */
#if defined(__CC_ARM)
extern uint32_t Image$$VECTOR_ROM$$Base[];
extern uint32_t Image$$VECTOR_RAM$$Base[];
extern uint32_t Image$$RW_m_data$$Base[];

#define __VECTOR_TABLE Image$$VECTOR_ROM$$Base
#define __VECTOR_RAM Image$$VECTOR_RAM$$Base
#define __RAM_VECTOR_TABLE_SIZE (((uint32_t)Image$$RW_m_data$$Base - (uint32_t)Image$$VECTOR_RAM$$Base))
#elif defined(__ICCARM__)
extern uint32_t __RAM_VECTOR_TABLE_SIZE[];
extern uint32_t __VECTOR_TABLE[];
extern uint32_t __VECTOR_RAM[];
#elif defined(__GNUC__)
extern uint32_t __VECTOR_TABLE[];
extern uint32_t __VECTOR_RAM[];
extern uint32_t __RAM_VECTOR_TABLE_SIZE_BYTES[];
#endif /* defined(__CC_ARM) */
uint32_t n;
uint32_t ret;
uint32_t irqMaskValue;

irqMaskValue = DisableGlobalIRQ();
if (SCB->VTOR != (uint32_t)__VECTOR_RAM)
/* Copy the vector table from ROM to RAM */
for (n = 0; n < ((uint32_t)__RAM_VECTOR_TABLE_SIZE) / sizeof(uint32_t); n++)
/* Point the VTOR to the position of vector table */
SCB->VTOR = (uint32_t)__VECTOR_RAM;

ret = __VECTOR_RAM[irq + 16];
/* make sure the __VECTOR_RAM is noncachable */
__VECTOR_RAM[irq + 16] = irqHandler;


return ret;

what i have to set the interrupt?


Tags (2)
0 Kudos
2 Replies

NXP Employee
NXP Employee

Hi Daniele Cortellazzi

__VECTOR_TABLE[], __VECTOR_RAM[] and __RAM_VECTOR_TABLE_SIZE_BYTES[] are normally defined in the linker file, you can corroborate that they are defined in this file, this linker file is normally inside the settings folder. Unless this, InstallIRQHandler function is used when you going to run the handler in RAM, there is not need to use it if you going to work normally. So for your handler definition you can only use UART4_RX_TX_IRQHandler, something like:

void UART4_RX_TX_IRQHandler(void)
     // Your own uart handler code

If you are using UART SDK drivers, you can find in startup_MK22F51212.S file that UART4_RX_TX_IRQHandler uses UART4_RX_TX_DriverIRQHandler, which is defined in the fsl_uart.c drivers.

Hope this information could help you.
Have a great day,
Jorge Alcala

Note: If this post answers your question, please click the Correct Answer button. Thank you!

Contributor I

   Can anybody explain how to declare those things in the linker script? I cannot find an example anywhere in the SDK. There are application examples, of course, and they declare such things but they create their own .ld files and declare a lot of other things there as well and that looks way to complex. What I'm looking for is something like if you use a function from fsl_common you have to add this block to the linker script, if you use another function from another driver you have to add that block to the linker script.

   Also, a side question is this. When a new C or C++ project is created, the wizard sets automatic managing of the linker script. Do I really have switch it to manual, to create my own file or can I combine the automatic managing and injections of the aforementioned blocks somewhere? If I have to replace the automatic managing with manual, how to do that? Apparently I have to preserve certain things that were already added automatically?

0 Kudos