STM32G0 USART3 and USART4 share an interrupt. How to deal with it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2023-05-02 9:44 PM
void USART3_IRQHandler(void) is incorrect, since USARTs 3/4 share the interrupt, it doesn't compile. What replaces 'USART3' in the interrupt handler?
NVIC_ClearPendingIRQ(USART3_IRQn); is incorrect since USART3 3/4 share the interrupt. What replaces 'USART3_IRQn' so that the NVIC_ClearPendingIRQ will compile?
Solved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2023-05-02 10:30 PM
The interrupt handler names are defined in the startup code, like in startup_stm32g070xx.s:
.word USART1_IRQHandler /* USART1 */
.word USART2_IRQHandler /* USART2 */
.word USART3_4_IRQHandler /* USART3, USART4 */
If you create code with UART 3/4 interrupts enabled, you find the code in stm32g0xx_hal_msp.c:
HAL_NVIC_SetPriority(USART3_4_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(USART3_4_IRQn);
Those defines are from CMSIS like stm32g070xx.h.
The generated code is correct and does compile without errors.
hth
KnarfB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2023-05-02 10:28 PM
You check and service both peripherals and the flags should clear.
I think in one of the recent threads it establishes the combined symbol and number for the IRQ. Grep the library source or truncate the Handler name seen in startup.s
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2023-05-02 10:30 PM
YOUR thread here https://community.st.com/s/question/0D53W00002FEy7wSAD/i-there-a-usart3irqn-and-a-usart4irqn-on-stm32g070
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2023-05-02 10:30 PM
The interrupt handler names are defined in the startup code, like in startup_stm32g070xx.s:
.word USART1_IRQHandler /* USART1 */
.word USART2_IRQHandler /* USART2 */
.word USART3_4_IRQHandler /* USART3, USART4 */
If you create code with UART 3/4 interrupts enabled, you find the code in stm32g0xx_hal_msp.c:
HAL_NVIC_SetPriority(USART3_4_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(USART3_4_IRQn);
Those defines are from CMSIS like stm32g070xx.h.
The generated code is correct and does compile without errors.
hth
KnarfB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2023-05-04 8:03 AM
Everyone, thanks for your help... compiles, so I presume that it will work.
