AnsweredAssumed Answered

STM32-MAT/TARGET. Tons Of Bugs: Error in code generation for USARTs with shared interrupts

Question asked by Dima Sagalov on Feb 26, 2018
Latest reply on Feb 27, 2018 by Dima Sagalov

Environment:

Windows10 (x64)

Matlab R2017a

STM32-MAT/TARGET-v4.4.2

STM32CubeMX-v4.24.0

STM32Cube MCU Package for STM32F0 Series -v1.9.0

SW4STM32-v2.4

TrueSTUDIO-v9.0.0

 

The STM32F030CC has 6 USARTs. USART1 and USART2 have separate interrupts. USART from 3 to 6 have one common interrupt. Apparently, STM32-MAT/TARGET searches for individual interrupts for each USART, because the code generated for USART1 and USART2 works correctly (via interrupts), but for USART3-USART6, STM32-MAT/TARGET generates the code as if they were working without interrupts, in polling mode (HAL_UART_Receive function). At the same time, the interrupt handler for USART3_6 is generated by the "Cube", but is not used during operation. It turns out completely incorrect work of the code.

That is, STM32-MAT/TARGET does not accept USART with common interrupts as working on interrupts. This is even seen in the Simulink USART blocks - Interrupt checkbox is unfilled for USART3 - USART6.

 

Here we use interrupts in Cube:

 

 

STM32-MAT/TARGET does not perceive them:

 

 

 

Bypass

1.

Add the following lines to the file *.ioc:

NVIC.USART3_IRQn=true\:0\:0\:false\:false\:true\:true

NVIC.USART4_IRQn=true\:0\:0\:false\:false\:true\:true

NVIC.USART5_IRQn=true\:0\:0\:false\:false\:true\:true

NVIC.USART6_IRQn=true\:0\:0\:false\:false\:true\:true

 

In Simulink blocks the Interrupt checkbox will be filled:

 

2. Save the file and change its properties to "Read only", because the code generator tries to overwrite the file with the original one and removes added lines. The code generator will curses (just click OK), but the process will be successful.

Outcomes