cancel
Showing results for 
Search instead for 
Did you mean: 

CAN module in STM32F722ZE Nucleo Board.

CTran.2
Associate II

I intend to use CAN module in STM32F722ZE Nucleo board, but I have a problem- the CAN module does not work.

I tried to see the example code, but it also is not run.

Anyone has the source code for CAN module in STM32F722ZE Nucleo? ( Loopback or normal mode)

Thank you so much

1 ACCEPTED SOLUTION

Accepted Solutions

I'm wondering why you're using 18 as CAN prescaler and value 1TQ for BS1 and BS2?

Could you please decrease the prescaler and increase BS1 and BS2 to match your bitrate, then test again?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

View solution in original post

7 REPLIES 7
PChia.2237
Senior

Post configuration clock and can.

Then try simple code:

CAN_FilterTypeDef sFilterConfig;

CAN_TxHeaderTypeDef sCanTxHeader;

CAN_RxHeaderTypeDef sCanRxHeader;

uint8_t TxCanBuf[8];

uint8_t RxCanBuf[8];

uint32_t TxMailbox;

main(void){

...

...

HAL_CAN_Start(&hcan1);

while(true){

TxCanBuf[0]=0;

TxCanBuf[1]=1;

TxCanBuf[2]=2;

TxCanBuf[3]=3;

TxCanBuf[4]=4;

TxCanBuf[5]=5;

TxCanBuf[6]=6;

TxCanBuf[7]=7;

sCanTxHeader.DLC=8;

sCanTxHeader.StdId=0x200;

sCanTxHeader.IDE=CAN_ID_STD;

sCanTxHeader.RTR=CAN_RTR_DATA;

HAL_CAN_AddTxMessage(&hcan1, &sCanTxHeader, TxCanBuf, &TxMailbox);

HAL_Delay(100);

}

SofLit
ST Employee

Hello,

If you are using just your Nucleo without any CAN node connected to the bus, the only mode you can use is Loopback mode.

If you have another CAN node connected to the bus i.e. normal mode (CAN_H/CAN_L), of course you have to use a transceiver with your Nucleo board. If it doesn't work, the first thing to check is your HW: all connections from your CAN_Rx/Tx, transceiver, termination resistors, CAN_H/CAN_L to the second node connected to the bus. The transceiver has to leave standby mode. So, check the transceiver datasheet, there is a pin dedicated for that.

Regarding the examples, you can refer to the examples available in CubeF7:

1- \Projects\STM32756G_EVAL\Examples\CAN\CAN_Loopback : loopback mode.

2- Projects\STM32756G_EVAL\Examples\CAN\CAN_Networking : normal mode.

The examples are compatible with F722, just you have to adapt your clocks and the CAN bitrate configs (BS1/BS2)

Hope this helps.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
CTran.2
Associate II

0693W00000KbdYVQAZ.jpg0693W00000KbdYWQAZ.jpg0693W00000KbdgFQAR.jpgI am using the Loopback mode to test the code for CAN module. The pointer is also passed through "HAL_CAN_AddTxMessage(&hcan1, &TxHeader, TxData, &TxMailbox)!= HAL_OK; "

But, the program is looping at "

/* wait transmision complete*/

while(HAL_CAN_GetTxMailboxesFreeLevel(&hcan1)!= 3)

I just use F722ZE Nucleo board, no additional configuration.

I also use STM32 CubeMx to generate the configuration code.

Thank you so much.

SofLit
ST Employee

As stated in the previous comment, you can refer to the example \Projects\STM32756G_EVAL\Examples\CAN\CAN_Loopback : loopback mode available in CubeF7.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

Hello,

I am using Loop back mode also refer the example code for CAN module at STM32F756G_EVAL.

But it does not work.

I also try to copy that project and modify to use F722ZE, but, it isn't successful.

Can you give me a project that work well at F722ZE board?

Thank you so much

I'm wondering why you're using 18 as CAN prescaler and value 1TQ for BS1 and BS2?

Could you please decrease the prescaler and increase BS1 and BS2 to match your bitrate, then test again?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.