Loading...
 

Zephyr project on STM32

   Zephyr Workbench, a VSCode extension to manage Zephyr on STM32.
It enables users to easily create, develop, and debug Zephyr applications.
Main features:
  • Install host dependencies.
  • Import toolchain and SDK.
  • Create, configure, build and manage apps.
  • Debug STM32.
You can directly download it from the VSCode marketplace
For more details, visit the Zephyr Workbench

System Workbench for STM32


You are viewing a reply to UART Character Match Interrupt  

UART Character Match Interrupt

Thanks MSchultz for the detailed response. That really helped me in getting the line break detection interrupt working properly. I was in the same situation as the original poster and was pulling my hair out.

Below are the interrupt handler and line break detection callback that worked for me. It was a little bit of a pain clearing all the flags plus reading from the ISR register so that the ISR would not re-enter. One thing I was not clear on is that there seems to be a distinction between status flags and interrupt flags. There seem to be a difference between the two.

/**
* Brief This function handles USARTx Instance interrupt request.
* Param None
* Retval None
*/
void USARTx_IRQHandler(void)
{
if ((LL_USART_IsActiveFlag_FE(USARTx_INSTANCE) || LL_USART_IsActiveFlag_LBD(USARTx_INSTANCE))
&& LL_USART_IsEnabledIT_LBD(USARTx_INSTANCE)
&& LL_USART_IsEnabledLIN(USARTx_INSTANCE)) {

/* Toss Receive Data */
LL_USART_ReceiveData8(USARTx_INSTANCE);
/* Clear ORE (Overrun Error) Flag */
LL_USART_ClearFlag_ORE(USARTx_INSTANCE);
/* Clear EOB (End of Block) Flag */
LL_USART_ClearFlag_EOB(USARTx_INSTANCE);
/* Clear FE (Frame Error) Flag */
LL_USART_ClearFlag_FE(USARTx_INSTANCE);

/* LBD flag will be cleared after reading of ISR register (done in call) */
/* Call function in charge of handling Character reception */
USART_LineBreak_Callback();
}

/**
* @brief Function called from USART IRQ Handler when LBD flag is set
* Function is in charge of reading line break received on USART RX line.
* @param None
* @retval None
*/
void USART_LineBreak_Callback(void)
{
__IO uint32_t isr_reg;

isr_reg = LL_USART_ReadReg(USARTx_INSTANCE, ISR);
if (isr_reg & LL_USART_ISR_LBDF) {
/* Toggle LED */
LL_GPIO_TogglePin(LED4_GPIO_PORT, LED4_PIN);

/* Clear LBD Flag */
LL_USART_ClearFlag_LBD(USARTx_INSTANCE);
}
}

All the code was based on this example:
https://github.com/STMicroelectronics/STM32CubeG0/tree/master/Projects/NUCLEO-G071RB/Examples_LL/USART/USART_Communication_Rx_ITQuestion

 

Newest Forum Posts

  1. Можно ли установить камин на балконе или лоджии? by Grand3kpdErorb, 03:38
  2. reservation car service Seattle by Jamesprede, 2025-05-01 10:06
  3. Last day: drone bonus by Danielrug, 2025-04-19 16:55
  4. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-25 07:37
  5. SPI on Nucleo_STMH533RE by royjamil, 2025-03-23 11:31
  6. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-23 09:33
  7. Configuring DMA for ADC in SW? by sam.hodgson, 2025-03-04 12:58
  8. Insightful Perspectives on This Subject by davidsycle, 2025-03-04 05:45
  9. Build a project in "release" mode by info@creosrl.it, 2025-02-20 18:12
  10. Build a project in "release" mode by info@creosrl.it, 2025-02-20 17:05

Last-Modified Blogs