cancel
Showing results for 
Search instead for 
Did you mean: 

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

Dima Sagalov
Associate II
Posted on February 26, 2018 at 04:19

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:

0690X00000609oiQAA.png

STM32-MAT/TARGET does not perceive them:

0690X00000609X9QAI.png

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:

0690X00000609g1QAA.png

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.

#simulink #stm32-mat/target-matlab
1 ACCEPTED SOLUTION

Accepted Solutions
Posted on February 27, 2018 at 08:42

Hi,Dima

The bug is fixed.

Please following this i

nstruction:

1. Replace (Overwrite) the following files in to STM32-MAT/TARGET installation path: \MATLAB\STM32-MAT\STM32\blks\masks

1.1 USART_Receive_callback.p

1.2 USART_Send_callback.p

Best regards,

________________

Attachments :

patch_USART_block_update1.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hxvu&d=%2Fa%2F0X0000000b2P%2FJ_LvSz.L2FBN4apuhe.3FUyGuJ5wA7UCO5lHIuT5kBI&asPdf=false

View solution in original post

2 REPLIES 2
Posted on February 27, 2018 at 08:42

Hi,Dima

The bug is fixed.

Please following this i

nstruction:

1. Replace (Overwrite) the following files in to STM32-MAT/TARGET installation path: \MATLAB\STM32-MAT\STM32\blks\masks

1.1 USART_Receive_callback.p

1.2 USART_Send_callback.p

Best regards,

________________

Attachments :

patch_USART_block_update1.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hxvu&d=%2Fa%2F0X0000000b2P%2FJ_LvSz.L2FBN4apuhe.3FUyGuJ5wA7UCO5lHIuT5kBI&asPdf=false
Dima Sagalov
Associate II
Posted on February 27, 2018 at 13:58

Hi!...

Promptly! )))

Thank you!