2024-03-24 09:33 AM - last edited on 2024-03-24 10:12 AM by SofLit
I have a STM32F303 connected to a L9616 as displayed below.
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
Solved! Go to Solution.
2024-03-24 10:08 AM - edited 2024-03-24 10:18 AM
Hello,
I don't see an issue in the schematics but I have some questions:
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.
2024-03-24 10:08 AM - edited 2024-03-24 10:18 AM
Hello,
I don't see an issue in the schematics but I have some questions:
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.
2024-03-24 10:50 AM - edited 2024-03-24 11:01 AM
Thanks a lot for your answer, @SofLit
I provide answers for your questions below.
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)?
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.
Yes, there is. Same settings.
External crystal, 16MHz.
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.
2024-03-24 11:20 AM
@SofLit, do you recommend another CAN transceiver from ST to substitute L9616?
2024-03-24 01:12 PM - edited 2024-03-24 01:17 PM
You are on a 3v3 cpu, so better use a 3v3 compatible CAN transceiver , like:
sn65hvd255
https://www.mouser.de/c/?marcom=139712041
or
https://www.mouser.de/datasheet/2/268/MCP2542FD_MCP2542WFD_4WFD_Data_Sheet_DS20005514C-1890692.pdf
MCP2542FD
or any...
2024-03-24 01:23 PM - edited 2024-03-24 01:28 PM
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:
I think no need to connect it for the moment. In this configuration you are in High speed config > 250kb/s
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):
According to its datasheet this transceiver fit exactly your needs. Power supply = 5V and VIH min = 2V < 3.3V
2024-03-24 04:56 PM
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.
2024-03-24 05:41 PM
Hello, @SofLit. I'm writing to tell you that I have just ordered a few MCP2561. Thanks a lot for your suggestion.
2024-03-24 08:12 PM
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.
2024-03-25 12:40 AM
Hello again,
I tried to simulate your config and found that you have a non-common CAN bitrate:
This is your system clock config:
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.