cancel
Showing results for 
Search instead for 
Did you mean: 

Nucleo-F091RC CAN Bus not communicating

I am using the Nucleo-F091RC board to communicate with a Motor that allows me to change it's speed with CAN.  I have the nucleo board attached to an Adafruit CAN Pal board which has a TJA1051T/3 from NXP as the CAN transceiver but I have yet to actually connect the motor to the CAN_H and CAN_L outputs from the transceiver.  I am powering the board with 3.3V generated by the nucleo board and the CAN signals attached to PA12 and PA11 and Silent pin connected to PB12 generating a low signal all the time to make sure the transceiver is in "normal" mode.  I have been able to get the nucleo board to output a CAN message every 65ms and I can see it on the CAN_TX pin being output from the nucleo board to the adafruit CAN Pal.  When I attach my scope to the output of the transceiver (CAN_H) the signal is always High...no data.

Here is my CAN setup code:

static void MX_CAN_Init(void)
{

/* USER CODE BEGIN CAN_Init 0 */

/* USER CODE END CAN_Init 0 */

/* USER CODE BEGIN CAN_Init 1 */

/* USER CODE END CAN_Init 1 */
hcan.Instance = CAN;
hcan.Init.Prescaler = 16;
hcan.Init.Mode = CAN_MODE_NORMAL;
hcan.Init.SyncJumpWidth = CAN_SJW_2TQ;
hcan.Init.TimeSeg1 = CAN_BS1_2TQ;
hcan.Init.TimeSeg2 = CAN_BS2_3TQ;
hcan.Init.TimeTriggeredMode = DISABLE;
hcan.Init.AutoBusOff = DISABLE;
hcan.Init.AutoWakeUp = ENABLE;
hcan.Init.AutoRetransmission = DISABLE;
hcan.Init.ReceiveFifoLocked = DISABLE;
hcan.Init.TransmitFifoPriority = ENABLE;
if (HAL_CAN_Init(&hcan) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN CAN_Init 2 */
HAL_GPIO_WritePin(CAN_Silent_GPIO_Port, CAN_Silent_Pin, CAN_SILENT_DEFAULT);
/* USER CODE END CAN_Init 2 */

}

Since the motor can't talk back to me I am not setting up anything to do with receiving data from the CAN bus.  Can anyone help me with why I would be seeing data coming from the MCU but then the transceiver not then transmitting that data onto the bus?  Does the transceiver need to be connected to a CAN Bus in order for data to appear on it?  I've tested similar CAN devices that transmit data and they do not seem to have to be connected to the bus for data to appear on CAN_H.

18 REPLIES 18

I have implemented the changes you suggested and the Nucleo board powers up and seems to run ok as long as I'm plugged into a PC...once I try to power the board off a 5V external supply nothing works.  I believe i've followed the instructions on powering the board externally correctly...

1) move JP5 to pins 2 and 3

2) Remove JP1

3) Attach external 5V to E5V pin on CN7 (pin 6)

The LEDs on the Nucleo board come on but nothing seems to work beyond that.  I suspect the external 8MHz being generated by the STLink portion isn't coming up...does this HAVE to be plugged into a PC to work?

That's strange.

According to the schematics, ST-LINK still powered even you are using an external power supply:

SofLit_0-1689088657202.png

So yes if ST-Link is no more powered, no 8MHz outputted for your MCU.

Check the power supply on JP6.

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.

For now I will just power this with my PC to get it working again.  Once I do this, I am getting this steady state communication out of my Nucleo board and through the CAN transceiver once the motor stops trying to talk on the bus...however it's only transmitting on the CAN_L wire...nothing seems to happen on the CAN_H:

NicholasYunker_2_0-1689106008410.png

This is what it looks like when the motor initially starts up and seems to take over the CAN Bus and I see no traffic from the Nucleo board at all:

NicholasYunker_2_1-1689106236000.png

1) I don't really understand why the motor is talking on CAN_H and the Nucleo board talks on the CAN_L.  I thought these two wires were supposed to be directly opposite of each other all the time.

2) Why would the motor be hogging the line initially and then after 10-20 seconds it stops talking at all and then the Nucleo board seems to be allowed to talk?

Hello,

Again, this is also weird. As you said CAN_H and CAN_L should be opposite to represent differential levels. 

Did you already check your wiring continuity?

I think at this stage, you need to surround the issue by using two STM32 communicating each other with CAN. If it was ok, I suspect something from the motor controller unit.

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.
SofLit
ST Employee

Also for your issue with power, check VIO voltage level of your transceiver on Pin 5 when you switch from PC to an external power supply. 

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.

I was just able to confirm what wire should be CAN_H and which one should be CAN_L.  I did in-fact have them backwards.  When I connected them correctly all data transmissions only appear on the CAN_L, both data sent from the Nucleo board to the Motor as well as from the motor to the Nucleo board.  Here are some screen shots (data 1 = CAN_TX, data 0 = CAN_H, data 2 = CAN_L):

NicholasYunker_2_0-1689170918063.png

NicholasYunker_2_2-1689171079572.png

NicholasYunker_2_4-1689171185684.png

NicholasYunker_2_6-1689171253881.png

NicholasYunker_2_8-1689171323010.png

 

I did check to see if I disconnect the motor from the CAN Bus and only have the Nucleo board on it, the CAN_H signal still remains high the whole time.  I figured this would rule out the issue being with the motor controller...

LCE
Principal

Maybe you already damaged the transceiver? But they are usually very robust.

Anyway, do you have another CAN board and or another Nucleo?

Have you already tested your firmware with the external loopback mode?

I would also check the logic analyser settings and connections, and I would instead connect an oscilloscope, just to be sure...

My apologies...I used the oscilloscope probes instead of the logic probes and now I see both CAN_H and CAN_L signals as I would expect.  I am still new to CAN and I wasn't aware that the "zero" for CAN is actually 2.5V...with that in mind here is the CAN_H and CAN_L with the decoded message coming from the Nucleo board:

NicholasYunker_2_0-1689185806420.png

As for why the motor is not responding I believe I may have to take that up with the motor manufacturer.  Thank you for your assistance!