AnsweredAssumed Answered

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

Question asked by Radu Ghiga on May 3, 2018
Latest reply on May 24, 2018 by T J

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 FW 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

Outcomes