2017-11-15 01:40 PM
I am trying to make the can interface work on the STM32F4Discovery board.
I did create a project with Cube, and noted CAN1 as being on PD0 and 1.
Then I created a can message and am trying to send it through CAN1 with HAL_CAN_Transmit...
My circuit, only the pins PD0 and 1 are pulled up to 3V, rest is left alone , as I want to see something happen on those pins.
I see in the debugger that:
1) When pulling down PD0 or PD1, CAN does not initialize - It fails with timeout in the initialization of the hardware
2) When pulling up PD0 and PD1, CAN does initialize
3) When doing the HAL_CAN_Transmit, it fails with a timeout.
If I connect a oscilloscope on the PD0 and 1, they are both high and do not toggle; nothing happens.
Question: Without anything connected to the pins except a pullup (2k resistor) should I expect something to happen?
This is my code for trying to send messages:
CanTxMsgTypeDef mes;
mes.DLC = 8; //Length of data mes.Data[0] = 0; mes.ExtId = 1; mes.IDE = CAN_ID_STD; mes.RTR = CAN_RTR_DATA; mes.StdId = 1; hcan1.pTxMsg = &mes; /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ HAL_CAN_Transmit(&hcan1, 100); /* USER CODE BEGIN 3 */}
I added a zip file with the src and inc folder of my project...
What is the best way to proceed here? Do I need some more circuitry, to get things going?
Thanks for pointing me into the right direction.
#can-communitation #stm32f4discoverySolved! Go to Solution.
2017-11-15 04:14 PM
You need transceiver where CANRX can see what CANTX is driving on the bus, and then you'll need a receiving device to acknowledge reception of the packet.
Look at schematics for the EVAL series boards, and other threads on forum.
2017-11-15 04:14 PM
You need transceiver where CANRX can see what CANTX is driving on the bus, and then you'll need a receiving device to acknowledge reception of the packet.
Look at schematics for the EVAL series boards, and other threads on forum.
2017-11-19 03:05 AM
This was usefull. I added a small circuitry, with a pullup to VDD, with 1k resistor and diodes on the TX pins so they can pulldown the can bus.
The signals start coming up, and with 2 nodes I see the other node acknowledging the can message.
(Next step is to add a 1051 can controller)
Great, thanks!