Reputation: 1
How do I handle an interrupt for an ARM microcontroller using codewarrior?? In the HCs08 processors I do this, for example:
interrupt VectorNumber_Vsci1rx void ISR_name(void)
{
.....Do something......
}
after enable interrupts, of course... But I don't know how to handle these interrupts in ARM processors using codewarrior or KDS
Upvotes: 0
Views: 1506
Reputation: 1
I don’t have Codewarrior or KDE by hand. But all ARM-Controllers which follow the ARM-CMSIS Standard are going this way.
All the interrupt Handlers of the controller are already defined but with __weak linkage. So, all you have to do is to create a function with the same Name.
For example compare the File devices\MK22F51212\arm\startup_MK22F51212.s from the MCUXpresso SDK for the FRDM-K22 Board: https://mcuxpresso.nxp.com/en/dashboard
Upvotes: 0
Reputation: 107
What version of CodeWarrior are you using? Which toolset are you using? If you're using the GCC toolset, the interrupt names are different and are weakly tied to a default handler. Just create an interrupt with the correct name and it will work. If you aren't using the GCC toolset, you have to edit the arrays in kinetis_sysinit.c.
Upvotes: 0
Reputation: 4809
I was using a Kinetis K20 (K20DX128VLH5) with Codewarrior for MCU and used this approach. In order to declare a certain method as the handler for an event, find the class kinetis_sysinit.c that should be auto-generated with any project. There you'll find a method that looks like the following code I posted. This is the interrupt vector table. If you're using something from the K20 Sub-Family, download the K20 Sub-Family reference manual. Starting on page 62 of the ref manual you can find which vector corresponds to which module.
NOTE: The process may differ depending on what type of Kinetis you're using (K20 vs K40 vs K60 etc). Look to the device's reference manual to find out what interrupt vectors correspond to what.
In the following code you can see I added in a few methods of my own to handle GPIO, UART and timer interrupts.
/* The Interrupt Vector Table */
void (* const InterruptVector[])() __attribute__ ((section(".vectortable"))) =
{
/* Processor exceptions */
(void(*)(void)) &_estack, // Vector 0
__thumb_startup, // Vector 1
NMI_Handler, // Vector 2
HardFault_Handler,
MemManage_Handler,
BusFault_Handler,
UsageFault_Handler,
0,
0,
0,
0,
SVC_Handler,
DebugMonitor_Handler,
0,
PendSV_Handler,
SysTick_Handler,
/* Interrupts */
Default_Handler, // Vector 16
Default_Handler, // Vector 17
Default_Handler, // Vector 18
Default_Handler, // Vector 19
Default_Handler, // Vector 20
Default_Handler,
Default_Handler,
Default_Handler,
Default_Handler,
Default_Handler,
Default_Handler,
Default_Handler,
Default_Handler,
Default_Handler,
Default_Handler, // Vector 30
Default_Handler,
(tIsrFunc)uart_status_handler, // 32 is UART0 status sources
Default_Handler, // 33 is UART0 error sources
Default_Handler,
Default_Handler, // Vector 35
Default_Handler,
Default_Handler,
Default_Handler,
Default_Handler,
Default_Handler, // Vector 40
Default_Handler,
Default_Handler,
Default_Handler,
Default_Handler,
Default_Handler, // Vector 45
Default_Handler,
Default_Handler,
Default_Handler,
Default_Handler,
Default_Handler, // Vector 50
Default_Handler,
Default_Handler,
Default_Handler,
Default_Handler,
(tIsrFunc)timer_handler, // Vector 55, LPTMR
Default_Handler, //(tIsrFunc)portA_button_handler, // Vector 56, port A pin detect
Default_Handler,
(tIsrFunc)portC_button_handler, // Vector 58, port C pin detect
Default_Handler,
Default_Handler,
Default_Handler,
};
In the same class, be sure to also declare your methods externally. Right below the typedef struct for tIsrFunc towards the top, write something like this:
extern void timer_handler(void);
extern void portC_button_handler(void);
extern void uart_status_handler(void);
Upvotes: 0