2018-05-03 05:53 AM
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 #simulink2018-05-03 08:34 AM
Hello
radu.ghiga
,HAL CAN driver has been reworked with new API to bypass limitations in the old releases.
Please, ensurethat you use latest tools (STM32CubeMx and
STM32MAT/Target),
then let me know whether the problem here persists or not.
We will check this issue internally.
Best Regards,
Imen
2018-05-04 12:53 AM
Hello Imen,
I have checked the versions I am using and I have the following:
STM32CubeMx Version 4.25.0
STM32-Mat/Target Version 4.4.2
STM32F7 FW 1.11.0
Matlab/Simulink 2017b
Atolic TrueStudio for STM32 Version 9.0.0
I have also checked on my.st.com website to see which are the active versions and these are the latest I could find.
Thank you and best regards,
Radu
2018-05-04 04:15 AM
With .ioc file from
https://community.st.com/0D50X00009XkWQdSAN
. ________________ Attachments : Nucleo_CAN.ioc.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HxeA&d=%2Fa%2F0X0000000b0S%2FQw13h2SnZbKAJZM0ouHsbvr25r6F69fqXDW0qseJNmY&asPdf=falseTo give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2018-05-04 06:53 AM
Yes Amel that is correct.
Thank you. I will keep this discussion here to avoid having multiple places with the same questions!
Best regards,
Radu
2018-05-19 09:48 AM
Hello
Same problem here... but just using bare STM32 tools.
STM32CubeMx Version 4.25.1 to generate the project
STM32F7 FW 1.11.0
STM32F769I-Disco and
SystemWorkbench
Only the following structures are defined in stm32f7xx_hal_can.h
CAN_InitTypeDef
CAN_FilterTypeDef
CAN_TxHeaderTypeDef
CAN_RxHeaderTypeDef
CAN_HandleTypeDef
The last one has no pointer fields for CAN packets... as stated in section 8.1.5 in document UM1905 User manual Description of STM32F7 HAL and Low-layer drivers DocID027932 Rev 3
Any hint on what I am doing wrong?
2018-05-20 04:15 PM
dont forget to pull up the Rx pin, if you are not using the CanBus Transceiver chip.
2018-05-23 10:43 AM
Thank you four your kind advise... I had designed an arduino board with a transceiver on it to connect the board with an existing design.
Any update or hint on the original issue?
Thank you.
2018-05-23 05:40 PM
In my personal code I have this :
void CAN_Config() {
CAN_FilterConfTypeDef sFilterConfig; static CanTxMsgTypeDef TxMessage; static CanRxMsgTypeDef RxMessage;....}
in STM32F7xx_hal_can.h
typedef struct
{ CAN_TypeDef *Instance; /*!< Register base address */CAN_InitTypeDef Init; /*!< CAN required parameters */
CanTxMsgTypeDef* pTxMsg; /*!< Pointer to transmit structure */
CanRxMsgTypeDef* pRxMsg; /*!< Pointer to reception structure for RX FIFO0 msg */
CanRxMsgTypeDef* pRx1Msg; /*!< Pointer to reception structure for RX FIFO1 msg */
__IO HAL_CAN_StateTypeDef State; /*!< CAN communication state */
HAL_LockTypeDef Lock; /*!< CAN locking object */
__IO uint32_t ErrorCode; /*!< CAN Error code. This parameter can be a value of @ref CAN_Error_Code */
}CAN_HandleTypeDef;2018-05-29 10:17 AM
Thank you TJ, In my case and with the given toolchain installation (see above) I get
/**
* @brief CAN handle Structure definition */typedef struct __CAN_HandleTypeDef{ CAN_TypeDef *Instance; /*!< Register base address */CAN_InitTypeDef Init; /*!< CAN required parameters */
__IO HAL_CAN_StateTypeDef State; /*!< CAN communication state */
__IO uint32_t ErrorCode; /*!< CAN Error code.
This parameter can be a value of @ref CAN_Error_Code */} CAN_HandleTypeDef;
I ended up generating the driver with an older version of the tools (CubeMx 4.17 and FW 1.5.1 ) and adapting/renaming the fields names to match the ones generated by the newer version... With these adapted files I have been able to run my own loopback demo.
Now I notice I had overlooked the
RX FIFO1
field.... but so far, so good.
Regards