AnsweredAssumed Answered

STM32F407-Discovery CAN bus problem

Question asked by Levinson.Isak on Jul 20, 2015
Latest reply on Jul 21, 2015 by Mark Edwards
Hi Guys,
I'm struggling to activate the can bus in the CAN2 module in the discovery eval board.
Using CubeMx, Generated all the initialization code.
Set baud-rate to 50KHz, and to loop-back mode.
The output waveform looks very strange, and does not change as a result of the transmitted data or ID. The returned status is 3, which is timeout.
Attached my test code, and the scope waveform from the CAN2-tx on PB6.
main.c includes all the default initialization, created by cube.
Here is the transmission code:
     HAL_StatusTypeDef          status;
     static     CanTxMsgTypeDef          txMsg;
     static     CanRxMsgTypeDef          rxMsg;
     static     CAN_FilterConfTypeDef     sFilterConfig;

     hcan2.pTxMsg     = &txMsg;
     hcan2.pRxMsg     = &rxMsg;

     txMsg.StdId     = 0x7ff;
     txMsg.ExtId     = 0;
     txMsg.IDE     = CAN_ID_STD;
     txMsg.RTR     = CAN_RTR_DATA;
     txMsg.DLC     = 2;
     txMsg.Data[0]     = 0x12;
     txMsg.Data[1]     = 0x34;

     status = HAL_CAN_Transmit(&hcan2, 1000);
     PRINT("%d\n", status);

Thanks, Isak.