cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F303 and L9616 CAN transceiver

enhering
Associate III

I have a STM32F303 connected to a L9616 as displayed below. 

enhering_0-1711296523818.png

enhering_1-1711296567728.png

The pullup resistor R3 is not present any more. Please ignore it. 
Vdd is 3.3V but, as can be seen, I have set Vs to 5V, believing that was necessary to make the CAN BUS work.

With an oscilloscope channel connected between CAN_BUS_H and GND I can see a Tx pulse train, but STM32 HAL reports state 2 and error 43 (0x2B) after transmission. If I understood well, this means 0x20 + 0x10 + 0x1 which leads me to believe that the following three errors are occurring:

#define HAL_CAN_ERROR_EWG (0x00000001U) /*!< Protocol Error Warning */
#define HAL_CAN_ERROR_FOR (0x00000010U) /*!< Form error */
#define HAL_CAN_ERROR_ACK (0x00000020U) /*!< Acknowledgment error

Besides that reported error, the most annoying fact is that I tried many ways to fire the Rx Callbacks on another node with similar configurations, without success. 

When investigating the problem I measured, on the reception node, CAN_TX at 3.3V and CAN_RX at 5V. I believe this 5V at CAN RX is, somehow, blinding STM32 from the Rx transceiver signal. 

Can you help me with some information? Or could you please share a proved working connection diagram between STM32 and L9616 with me? 

Best regards,

Hering

1 ACCEPTED SOLUTION

Accepted Solutions
SofLit
ST Employee

Hello,

I don't see an issue in the schematics but I have some questions:

  • How you did connect ASC pin? (the status of JP1).
  • Did you fit JP2 jumper to connect the termination resistor to the bus?
  • Is there another node connected to the bus that interacts with your node? If not, you have to connect another node having the same CAN bitrate.
  • What is the clock source you are using HSE with an external crystal or HSI?
  • Could you please provide your CAN bitrate configuration? CAN prescaler, BS1 and BS2? If you can share your code.

Besides that, I see another issue with the transceiver L9616 which is a 5V transceiver.

According to its datasheet VTXO min is 0.7 x Vs. In your case Vs = 5V -> So VTXO min = 0.7 x 5 = 3.5V that needs to be seen from the STM32. In your case, the latter is supplied by 3.3V and the GPIOs cannot deliver more than VDD = 3.3V. So it's out of spec of the transceiver. You need to supply your transceiver with maximum 4.71V (3.3/0.7) to be in the transceiver's spec.

SofLit_0-1711299774998.png

 

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

23 REPLIES 23
SofLit
ST Employee

Hello,

I don't see an issue in the schematics but I have some questions:

  • How you did connect ASC pin? (the status of JP1).
  • Did you fit JP2 jumper to connect the termination resistor to the bus?
  • Is there another node connected to the bus that interacts with your node? If not, you have to connect another node having the same CAN bitrate.
  • What is the clock source you are using HSE with an external crystal or HSI?
  • Could you please provide your CAN bitrate configuration? CAN prescaler, BS1 and BS2? If you can share your code.

Besides that, I see another issue with the transceiver L9616 which is a 5V transceiver.

According to its datasheet VTXO min is 0.7 x Vs. In your case Vs = 5V -> So VTXO min = 0.7 x 5 = 3.5V that needs to be seen from the STM32. In your case, the latter is supplied by 3.3V and the GPIOs cannot deliver more than VDD = 3.3V. So it's out of spec of the transceiver. You need to supply your transceiver with maximum 4.71V (3.3/0.7) to be in the transceiver's spec.

SofLit_0-1711299774998.png

 

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.

Thanks a lot for your answer, @SofLit 
I provide answers for your questions below.

  • How you did connect ASC pin? (the status of JP1).

Currently it is floating. I tried both JP1 possibilities with an external jumper, but saw no noticeable differences in the pulse train on the oscilloscope screen, so I disregarded it. Should I set it in the high bandwidth option (GND)?

  • Did you fit JP2 jumper to connect the termination resistor to the bus?

The jumper is fitted, but the resistor is not connected. I have placed two 120 ohm resistors in the bus endings instead. The bus is a vertical PCB which connects the modules.

MUVeCMarch2024.jpg 

  • Is there another node connected to the bus that interacts with your node? If not, you have to connect another node having the same CAN bitrate.

Yes, there is. Same settings.

  • What is the clock source you are using HSE with an external crystal or HSI?

External crystal, 16MHz.

  • Could you please provide your CAN bitrate configuration? CAN prescaler, BS1 and BS2? If you can share your code.

Sure:
hcan.Instance = CAN;
hcan.Init.Prescaler = 2;
hcan.Init.Mode = CAN_MODE_NORMAL;
hcan.Init.SyncJumpWidth = CAN_SJW_1TQ;
hcan.Init.TimeSeg1 = CAN_BS1_5TQ;
hcan.Init.TimeSeg2 = CAN_BS2_5TQ;
hcan.Init.TimeTriggeredMode = DISABLE;
hcan.Init.AutoBusOff = ENABLE;
hcan.Init.AutoWakeUp = ENABLE;
hcan.Init.AutoRetransmission = DISABLE;
hcan.Init.ReceiveFifoLocked = DISABLE;
hcan.Init.TransmitFifoPriority = DISABLE;

Again, thank you for your help.

@SofLit, do you recommend another CAN transceiver from ST to substitute L9616?

SofLit
ST Employee

Thank you for these information.

Could you please share your system clock config?

By this statement: "With an oscilloscope channel connected between CAN_BUS_H and GND I can see a Tx pulse train" : do you mean that you are seeing CAN frame transmitted by STM32 or from another node?

What about CAN_BUS_L? Are you seeing an expected signal?

Regarding ASC pin and according to L9616 datasheet, the pin is pulled down to GND through an internal resistor:

SofLit_0-1711311194595.png

I think no need to connect it for the moment. In this configuration you are in High speed config > 250kb/s

SofLit_1-1711311359881.png

Regarding your last question about a transceiver replacement and since your HW is already fixed, I would suggest MCP2561 which is pin to pin compatible with L9616 (unfortunately there is no replacement from ST):

SofLit_3-1711311732595.png

According to its datasheet this transceiver fit exactly your needs. Power supply = 5V and VIH min = 2V < 3.3V

SofLit_2-1711311694584.png

 

 

 

 

 

 

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.

Thank you, @SofLit  and @AScha.3  for your answers.
 
This is my system clock configuration:
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
  RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};

  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
  RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
  RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
  |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSE;
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV2;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV8;

  PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART2|RCC_PERIPHCLK_TIM1
|RCC_PERIPHCLK_TIM8;
  PeriphClkInit.Usart2ClockSelection = RCC_USART2CLKSOURCE_PCLK1;
  PeriphClkInit.Tim1ClockSelection = RCC_TIM1CLK_HCLK;
  PeriphClkInit.Tim8ClockSelection = RCC_TIM8CLK_HCLK;
  HAL_RCC_EnableCSS();

>> By this statement: "With an oscilloscope channel connected between CAN_BUS_H and GND I can see a Tx pulse train" : do you mean that you are seeing CAN frame transmitted by STM32 or from another node?

I can see the CAN frame transmitted from another, similar node. It is another module from the system, based on same MCU and same transceiver, with same settings.

>> What about CAN_BUS_L? Are you seeing an expected signal?
Yes. It can be seen on both H and L lines.

About the transceiver replacement, would also sn65hvd230 be a good replacement? It is also package and pin compatible with L9616.

Thanks again for your kind answers.


enhering
Associate III

Hello, @SofLit. I'm writing to tell you that I have just ordered a few MCP2561. Thanks a lot for your suggestion.

sn65hvd230 is a 3.3V transceiver, since your HW is fixed and your transceiver power supply is 5V. I suggested MCP2561. If your HW is not fixed you can use sn65hvd230.

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 again,

I tried to simulate your config and found that you have a non-common CAN bitrate: 

SofLit_0-1711352048178.png

This is your system clock config:

SofLit_1-1711352121001.png

Could you please confirm?

Regarding MCP2561 has STBY pin which consists of putting the transceiver in standby mode. In that case you couldn't transmit/receive any CAN frame. There is an internal pull up resistor connected to that pin (by default standby mode activated). So you need to at least pull STBY pin to the ground.

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.