Visitor II
July 20, 2015
Question
STM32F407-Discovery CAN bus problem
- July 20, 2015
- 2 replies
- 1156 views
Posted on July 20, 2015 at 10:02
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. #can #stm32f407 #discovery
