cancel
Showing results for 
Search instead for 
Did you mean: 

CAN Bug When using Simulink with STM32-MAT/TARGET 4.4.2 and STM32F7 FW V_1.11.0

Radu Ghiga
Associate II
Posted on May 03, 2018 at 14:53

Hello,

I am currently learning about STM32 devices and I am working with a Nucleo-F767ZI which I am programing using a toolchain that consists of Simulink with the STM32-MAT/TARGET support package, STM32CubeMX with the STM32F7 FW V1.11.0, and TrueSTUDIO.

I am interested in configuring and using the CAN interface available on the Nucleo F767ZI and I have built a simple example in Simulink with a CAN1 Send block and a MCU Config block. The code generation is successful and I can load the project in TrueSTUDIO. However, when compiling I get the following error: 

'unknown type name 'CanTxMsgTypeDef'

After some reading I found out that the HAL CAN Driver has been changed since STM32F7 FW V1.9.0 and there is no typedef struct with the above name any longer. It has been replaced by the following structure which can be found in stm32f7xx_hal_can.h:

/**

* @brief CAN Tx message header structure definition

*/

typedef struct

{

uint32_t StdId; /*!< Specifies the standard identifier.

                           This parameter must be a number between Min_Data = 0 and Max_Data = 0x7FF. */

uint32_t ExtId; /*!< Specifies the extended identifier.

                            This parameter must be a number between Min_Data = 0 and Max_Data = 0x1FFFFFFF. */

uint32_t IDE; /*!< Specifies the type of identifier for the message that will be transmitted.

                             This parameter can be a value of @ref CAN_identifier_type */

uint32_t RTR; /*!< Specifies the type of frame for the message that will be transmitted.

                              This parameter can be a value of @ref CAN_remote_transmission_request */

uint32_t DLC; /*!< Specifies the length of the frame that will be transmitted.

                              This parameter must be a number between Min_Data = 0 and Max_Data = 8. */

                              FunctionalState TransmitGlobalTime; /*!< Specifies whether the timestamp counter value captured                               on start of frame transmission, is sent in DATA6 and DATA7 replacing pData[6] and pData[7].

                              @note: Time Triggered Communication Mode must be enabled.

                              @note: DLC must be programmed as 8 bytes, in order these 2 bytes are sent.

                              This parameter can be set to ENABLE or DISABLE. */

} CAN_TxHeaderTypeDef;

For some reason when using the STM32-MAT/Target 4.4.2 support package library in Simulink, the generated code still refers back to the old structure and, of course, the project doesn't compile since '

CanTxMsgTypeDef' cannot be found anymore. I believe this is also true for the CAN Receive.

Any ideas on how to bypass this issue? I have tried using STM32F7

mailto:F@

1.8.0 which has the old CAN Drivers, but I had no success, probably because Simulink is generating part of the code according to the old Driver and part of it according to the new one?! I am not really sure if this is true, though.

Maybe STM32-MAT/Target package needs an update to fix this? Or is there something that I am doing wrong?

Any ideas to help me achieve some progress would be very appreciated.

Thank you.

Radu Ghiga

#stm32-mat/target-matlab #can #stm32f7 #stm32cubemx #simulink
13 REPLIES 13
Posted on June 30, 2018 at 07:49

Hey Imen,

I've just come up against this issue, when following instructions targetting CAN HAL drivers before 

STM32Cube_FW_F4_V1.19.0.

Could you indicate where the updated API is documented? I'm particularly 

interested in what has replaced the use of 

`

hcan1.pTxMsg` and `hcan1.pRxMsg`.

Cheers,

Tom

Posted on June 30, 2018 at 23:14

Hello 

tom_msbit

 ,

In this discussion 

https://community.st.com/0D50X00009Xkg2MSAR

 have a look to the CAN presentation prepared by 

Panecki.Szymon.002

, which guides you to develop a simple CAN application with new API and how to migrate from old API to new API.

Hope this helps you.

With Regards,

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Posted on July 01, 2018 at 02:53

Thanks Imen! Looks very useful.

can you send me solid files for STM32-Mat/Target Version 4.4.2 as it now obsolete and I need it in my project..