cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F446 CAN as MASTER MODE Not able to add these codes these in static void MX_CAN1_Init(void) hcan1.pTxMsg=&myTxmessage; hcan1.pRxMsg=&myRxmessage;

Reshma
Associate II

0690X000008BVmgQAG.png

Hello 

I have configured my STM32F446RE MCU as master mode for CAN communication using STM32CUBEMX version 5.1.0 ..I have generated the code in uVision5-Keil .I'm not able to change the function--static void MX_CAN1_Init(void) where i need to include the following lines...

hcan1.pTxMsg=&myTxmessage;

hcan1.pRxMsg=&myRxmessage;

As shown in below figure, pTxMsg and pRxMsg doesn't show up in the list.After being typed it shows error while compiling .

So any help will be welcomed. 

7 REPLIES 7
turboscrew
Senior III

I don't think CAN_HandleTypeDef has such fields.

Reshma
Associate II

Thank you!...but when i build my code ,it is showing the following error,

0690X000008BhZHQA0.jpg

I have changed the MANAGE PROJECT TO USE GCC COMPILER (GNU) FOR ARM PROJECTS .Should I need to download any firmwares or drives such things?Any suggestions are welcomed.

turboscrew
Senior III

Do you have that compiler? And if, does your IDE know where it is?

Reshma
Associate II

Yes! I have downloaded it from --> https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads

But I am not able to check if the IDE recognizes it .Do i need to place the downloaded (GNU) folder in same location as IDE folder.What should i do now ?

Thanks in advance !

Reshma
Associate II

Can anyone help this out?

turboscrew
Senior III

I have never used Keil (I think). But when it comes to the messages, you need to define your own variables and give them as parameters to the sending function and receiving callback.

HAL_StatusTypeDef HAL_CAN_AddTxMessage(CAN_HandleTypeDef *hcan, CAN_TxHeaderTypeDef *pHeader, uint8_t aData[], uint32_t *pTxMailbox);

HAL_StatusTypeDef HAL_CAN_GetRxMessage(CAN_HandleTypeDef *hcan, uint32_t RxFifo, CAN_RxHeaderTypeDef *pHeader, uint8_t aData[]);

called from these:

void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan);

void HAL_CAN_RxFifo0FullCallback(CAN_HandleTypeDef *hcan);

void HAL_CAN_RxFifo1MsgPendingCallback(CAN_HandleTypeDef *hcan);

void HAL_CAN_RxFifo1FullCallback(CAN_HandleTypeDef *hcan);

turboscrew
Senior III

You probably have some toolchain selection menu buried in the menus of the IDE.

In eclipse-derivatives, it's usually in project properties.