2023-07-06 04:03 PM - last edited on 2023-07-07 06:45 AM by Amel NASRI
Hi
I have been trying to activate the callback function for the pushbutton in the SubGHz PingPong example, but with no luck.
I am using the BSP_PB_Init() to configure the pushbutton:
2023-07-06 04:32 PM
You say you implemented the callback but the code you show doesn't show a callback function. So we don't know if you are using the correct callback?
2023-07-06 04:37 PM
Sorry, i didn't paste the function header by mistake, here it is:
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
HAL_UART_Transmit(&huart2, "TEST: ", 7, 100);
}
These are the only steps I did so far:
1. Configure BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_EXTI)
2. Call the BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_EXTI);
3. Implement the callback function void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
I am not sure if I have to do something else, for example, enable an IRQ somewhere. I am using the SubGHz example.
thanks
2023-07-07 04:13 AM - edited 2023-07-07 04:13 AM
Don't put blocking functions in interrupts / callbacks.
Also consider setting flags, or using queue, as the EXTI interrupt might occur in the middle of some other blocking, or pending, UART function, and you really need to sequence interactions.
2023-07-07 04:55 AM
Hi Tesla, thanks for the tips. I need temporary user feedback to troubleshoot the ISR issue, so i choose UART. The same ISR fails with LEDs.
So my question is, if someone has experience with STM32 or with the SubGHz PingPong example, what did I miss to make the ISR operate and execute as expected ?
thanks
2023-07-07 06:15 AM
My scope of experience is fairly broad. I've used the STM32L0 in the Murata based LoRa DISCO. Using the earlier LRWAN libraries, and not auto-generating the code / framework.
Have you established that the UART works and outputs? Do the EXTI enter when the button is pressed? Call-backs occur under interrupt context, so other interrupts will be blocked unless they have priority that will preempt. You should probably flag that you got the EXTI, and respond / react elsewhere, say in the main() loop.
I'd probably feed the UART via a ring-buffer, and it's own interrupts.
Which pin is the button on? Do you have the right EXTI? Is the EXTI shared with other pins or DIO from the Semtech SX1276? There are perhaps CUBEL0 examples of EXTI for this or similar boards, review those in context.
2023-07-07 06:23 AM
Hi Tesla
Awesome, I am sure you will be able to help me out, as I am a new comer to STM32.
UART works normally in other parts of the code.
I did several LED blink test within the callback of the pushbutton to check if its callback is executed, but it is not. It has priority of zero, so it should be executed.
Button is on pin PB2 (the LoRa devkit). and it is not shared with other resources.
While using ARM from PSoC, there is a global interrupt function that i have to call to enable global interrupts, but i couldn't find a similar procedure in the STM32 help or examples. So I was wondering if I am missing a step to enable the ISR.