Skip to main content
Associate II
July 6, 2023
Question

PingPong Example, failing to run GPIO ISR

  • July 6, 2023
  • 6 replies
  • 2681 views

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:

void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode)
{
  GPIO_InitTypeDef GPIO_InitStruct;
 
  /* Enable the BUTTON Clock */
  BUTTONx_GPIO_CLK_ENABLE(Button);
  __HAL_RCC_SYSCFG_CLK_ENABLE();
 
  if (ButtonMode == BUTTON_MODE_GPIO)
  {
    /* Configure Button pin as input */
    GPIO_InitStruct.Pin = BUTTON_PIN[Button];
    GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
    GPIO_InitStruct.Pull = GPIO_PULLDOWN;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
    HAL_GPIO_Init(BUTTON_PORT[Button], &GPIO_InitStruct);
  }
 
  if (ButtonMode == BUTTON_MODE_EXTI)
  {
    /* Configure Button pin as input with External interrupt */
GPIO_InitStruct.Pin = PushButton_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(PushButton_GPIO_Port, &GPIO_InitStruct);
 
/* Enable and set Button EXTI Interrupt to the lowest priority */
NVIC_SetPriority(EXTI2_3_IRQn, 0);
HAL_NVIC_EnableIRQ(EXTI2_3_IRQn);
}
}
 
Then I implemented  the callback function:
{
HAL_UART_Transmit(&huart2, "TEST: ", 7, 100);
}
 
But there is no response.
I am missing something to configure ?
thanks
This topic has been closed for replies.

6 replies

Karl Yamashita
Principal
July 6, 2023

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?

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.CAN Jammer an open source CAN bus hacking toolCANableV3 Open Source
sgabranAuthor
Associate II
July 6, 2023

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

Tesla DeLorean
Guru
July 7, 2023

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.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..