This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software:
Hey there,
is there any interrupt handler generation by sysconfig or do I have to type the IRQ handler functions by myself?
Just asking because the sysconfig generates so many code snippets but i can't find any interrupt handler.
I could copy things like this from the example projects:
void GROUP1_IRQHandler(void) { switch (DL_Interrupt_getPendingGroup(DL_INTERRUPT_GROUP_1)) { case GPIO_SWITCHES_INT_IIDX: /* If SW is high, turn the LED off */ if (DL_GPIO_readPins( GPIO_SWITCHES_PORT, GPIO_SWITCHES_USER_SWITCH_1_PIN)) { DL_GPIO_setPins(GPIO_LEDS_PORT, GPIO_LEDS_USER_LED_1_PIN); } /* Otherwise, turn the LED on */ else { DL_GPIO_clearPins(GPIO_LEDS_PORT, GPIO_LEDS_USER_LED_1_PIN); } break; } }
but i would prefer generated code that directly fits my needs.
And just another question:
Is it possible to have two interrupt handler functions for falling and rising edge interrupt?
Or do I have to check pin input level on interrupt event and decide whether it is high or low.
Thanks a lot in advance!
Matze
Too answer the next question, you only get one handler, but you can choose which or both edges. Here is what the example does:
void GROUP1_IRQHandler(void) { switch (DL_Interrupt_getPendingGroup(DL_INTERRUPT_GROUP_1)) { case GPIO_SWITCHES_INT_IIDX: /* If SW is high, turn the LED off */ if (DL_GPIO_readPins( GPIO_SWITCHES_PORT, GPIO_SWITCHES_USER_SWITCH_1_PIN)) { DL_GPIO_setPins(GPIO_LEDS_PORT, GPIO_LEDS_USER_LED_1_PIN); } /* Otherwise, turn the LED on */ else { DL_GPIO_clearPins(GPIO_LEDS_PORT, GPIO_LEDS_USER_LED_1_PIN); } break; } }
Here is what the example does:
Yes, I copied this into my sourcecode.
When I flash and debug now, I always end up in the default handler, when my button is pressed:
Do I need to add the blue line to my ti_msp_config.h?
Unfortunately this line get's deleted once I build my project again.
I also added NVIC_EnableIRQ(GPIO_GRP_0_INT_IRQN);
to my main function.
And __WFI(); at the end of the main while(1).
And this is my IRQHandler:
void GROUP0_IRQHandler(void) { switch (DL_Interrupt_getPendingGroup(DL_INTERRUPT_GROUP_0)) { case GPIO_GRP_0_DI_BUTTON_IIDX: /* If SW is high, turn the LED off */ if( DL_GPIO_readPins(GPIO_GRP_0_PORT, GPIO_GRP_0_DI_BUTTON_PIN) ) // HIGH, also IRQ wg. steigender Flanke, also Tasterdruck beendet { flag_DI_BUTTON_state = UNPRESSED; } /* Otherwise, turn the LED on */ else { // LOW, also IRQ wg. fallender Flanke, also Tasterdruck gestartet flag_DI_BUTTON_state = PRESSED; } break; default: break; } }
My watch expression of the button state always stays "0".
Or is there anything else that I need to consider?
You need to use the sysconfig settings from the example to create a "group1" set of LED's, or put something equivalent in your program and change names accordingly.
Yes I did so.. or tried... but it does not work..
Well.. I have a group 0 for my button and a group 2 for my LED.. but that should not be the problem, right?
Or why do you write about group 1 and LEDs?
I guess I should add, does the example run correctly?
I tried the example on LaunchPad and on my custom PCB and it works.
But in my sourcecode I always end up in the default handler, once I press my button.
"Or why do you write about group 1 and LEDs?"
Because I was trying to remember the example by my bad memory. 8^)
Clearly, your IRQ handler is misnamed.
Oh, and anytime you end up in the generic stub, you can add this code I got from Brandon Fisher for the MSPM0G3507:
/* * These are traps for debugging when you find that your code * ends up in the default handler for some unknown reason. * To keep the compiler from complaining, comment out the ones * below if you already have a working handler for that vector. * */ void NMI_Handler(void){ __BKPT(0);} void HardFault_Handler(void){ __BKPT(0);} void SVC_Handler(void){ __BKPT(0);} void PendSV_Handler(void){ __BKPT(0);} void SysTick_Handler(void){ __BKPT(0);} void GROUP0_IRQHandler(void){ __BKPT(0);} void GROUP1_IRQHandler(void){ __BKPT(0);} void TIMG8_IRQHandler(void){ __BKPT(0);} void UART3_IRQHandler(void){ __BKPT(0);} void ADC0_IRQHandler(void){ __BKPT(0);} void ADC1_IRQHandler(void){ __BKPT(0);} void CANFD0_IRQHandler(void){ __BKPT(0);} void DAC0_IRQHandler(void){ __BKPT(0);} void SPI0_IRQHandler(void){ __BKPT(0);} void SPI1_IRQHandler(void){ __BKPT(0);} void UART1_IRQHandler(void){ __BKPT(0);} void UART2_IRQHandler(void){ __BKPT(0);} void UART0_IRQHandler(void){ __BKPT(0);} void TIMG0_IRQHandler(void){ __BKPT(0);} void TIMG6_IRQHandler(void){ __BKPT(0);} void TIMA0_IRQHandler(void){ __BKPT(0);} void TIMA1_IRQHandler(void){ __BKPT(0);} void TIMG7_IRQHandler(void){ __BKPT(0);} void TIMG12_IRQHandler(void){ __BKPT(0);} void I2C0_IRQHandler(void){ __BKPT(0);} void I2C1_IRQHandler(void){ __BKPT(0);} void AES_IRQHandler(void){ __BKPT(0);} void RTC_IRQHandler(void){ __BKPT(0);} void DMA_IRQHandler(void){ __BKPT(0);}
And you will know what to call your handler! As well as verify that the interrupt that interrupts is the interrupt that you expect to be interrupting.