Hello,
I am using two of STM32F415RG (more specifically http://www.mikroe.com/mini/stm32/). I made a CAN bus using MCP2551 as a transceiver and connected the two of them. They are successfully exchanging data. After that, I tried connecting a USB to CAN device so that my PC can also use the bus. The problem now is that the PC cannot exchange data with the microcontrollers. To try to debug everything I connected a Saleae logic analyzer and monitored the low line of the bus. Saleae Logic has a feature to decode CAN messages. It can successfully decode messages from PC but cannot decode messages from the microcontrollers. When I inspected the waveform the one generated by the microcontrollers looks very weird. I attached four screenshots, two are with the waveforms generated by a microcontroller and two are generated by the pc.
Here is my initialization code:
The pins are initialized correctly, as alternate function without pull. The bus is around 30cm long made from a twisted pair and terminated with 120Ohm resistor at each end. At the time of testing, only one MCU and UsbToCan were connected on the bus. Because they are waiting for ACK they are entering retransmission so that's the reason for so much data.
Thanks.
I am using two of STM32F415RG (more specifically http://www.mikroe.com/mini/stm32/). I made a CAN bus using MCP2551 as a transceiver and connected the two of them. They are successfully exchanging data. After that, I tried connecting a USB to CAN device so that my PC can also use the bus. The problem now is that the PC cannot exchange data with the microcontrollers. To try to debug everything I connected a Saleae logic analyzer and monitored the low line of the bus. Saleae Logic has a feature to decode CAN messages. It can successfully decode messages from PC but cannot decode messages from the microcontrollers. When I inspected the waveform the one generated by the microcontrollers looks very weird. I attached four screenshots, two are with the waveforms generated by a microcontroller and two are generated by the pc.
Here is my initialization code:
Code:
g_canHandle.Instance = CANx;
g_canHandle.pTxMsg = &g_txMessage;
g_canHandle.pRxMsg = &g_rxMessage;
g_canHandle.Init.TTCM = DISABLE;
g_canHandle.Init.ABOM = DISABLE;
g_canHandle.Init.AWUM = DISABLE;
g_canHandle.Init.NART = DISABLE;
g_canHandle.Init.RFLM = DISABLE;
g_canHandle.Init.TXFP = DISABLE;
g_canHandle.Init.Mode = CAN_MODE_NORMAL;
g_canHandle.Init.SJW = CAN_SJW_1TQ;
g_canHandle.Init.BS1 = CAN_BS1_14TQ;
g_canHandle.Init.BS2 = CAN_BS2_6TQ;
g_canHandle.Init.Prescaler = 16; // 125 kbps
HAL_CAN_Init(&g_canHandle);
Thanks.
Attachments
-
122 KB Views: 19
-
116.2 KB Views: 19
-
120.9 KB Views: 19
-
127.2 KB Views: 16