I have been trying to get the interrupt working. Just a simple interrupt from a switch. As I am using safeRTOS instead of FreeRTOS which is a similar component but not same. OSAL layer for hte safeRTOS has been defined properly. The port interrupts are getting called but not able to really get an interrupt on a specific pin. To an extent, not able to pin down on the issue right now. Any guides or documentation which figures out interrupt mechanism on FreeRTOS would help.
Thanks.
I have actually configured the event to generate code for that particular interrupt. Now that I am seeing the error as below
Also, I am using IAR embedded workbench 7.2 to build my own project file with all the generated the source code from KDS (PE).
Hi Kewal,
A quick test that can be done is inherent (but hidden) within KSDK_1.3 FreeRTOS power manager rtos demo.
C:\Freescale\KSDK_1.3.0\examples\twrk65f180m\demo_apps\power_manager_rtos_demo\power_manager_rtos_demo_freertos\iar
This example already sets up an interrupt handler for a push button switch on the board.
It takes some digging to find where all the magic is happening and making a small code edit too.
In board.h I had made edit:
#define BOARD_SW_NAME "SW3" | //DES was "SW1" |
In gpio_pins.c I enable the interrupt for kGpioSW1 (which really is SW3 on the twrk65f180m):
const gpio_input_pin_user_config_t switchPins[] = {
{
.pinName = kGpioSW1,
.config.isPullEnable = true,
.config.pullSelect = kPortPullUp,
.config.isPassiveFilterEnabled = false,
.config.isDigitalFilterEnabled = false,
.config.interrupt = kPortIntFallingEdge //DES was kPortIntDisabled
},
In gpio_pins.h header comments added:
enum _gpio_pins_pinNames{
kGpioSW1 = GPIO_MAKE_PIN(GPIOA_IDX, 10U), //DES SW3 on TWR-K65F180M Rev D
kGpioSW2 = GPIO_MAKE_PIN(GPIOA_IDX, 4U), //DES SW2 on TWR-K65F180M Rev D
...
Also in this header is following renaming:
#define BOARD_SW_LLWU_IRQ_HANDLER PORTA_IRQHandler
The PORTA_IRQHandler is a default that is weakly defined in startup_MK65F18.s file. When you implement the same name function in your application code you are overloading the function and it will be used. This happens in task_lpm.c.
In task_lpm.c is where the Interrupt handler has been defined for the power management demo but it also will clear the GPIO Port A interrupt flag (Note Any interrupt for Port A pins go to one interrupt routine and that routine if more robust would determine which pin was the interrupt source but our demo doesn't do that).
/* IRQ handler for switch/button. */
void BOARD_SW_LLWU_IRQ_HANDLER(void)
{
#if 1 //DES 0=test, 1=default code
PORT_HAL_ClearPortIntFlag(BOARD_SW_LLWU_BASE);
#else
GPIO_DRV_ClearPinIntFlag(kGpioSW1); //DES added...this does work too and the two statements are equivalent
#endif
}
Regards,
David