2024-02-13 10:55 AM - edited 2024-02-13 10:56 AM
Hello,
I am using stm32F407VGT board and I am trying to receive data from a can analyzer with stm32 board. I transmit a data to stm32 boards but ı cant receive the messages. I can work on normal mode with two stm32 boards succesfully. The messages are received and transmitted. At the same time, I want to transmit data to can analyzer and I want to observe communication. I attached my main and interrupt source files and I am using USB-CAN analyzerV8 device. The can bps values are the same 500kbps. The modes are same as Normal Mode and I dont define a filter so ı can read every data that ı sent from can analyzer in live expression on debug screen.
Summarize,
All my purpose, I want to see data that ı sent from can analyzer in my live expression part. I am sending one message fisrtly so there is a one Id.
2024-02-13 11:29 AM
Are you sure on the speed?
What's your external clock? What's the AHB, APB1 and APB2 bus speeds.
Are you monitoring the two talking, or just one into the analyzer?
This looks wrong, but unrelated.
sFilterConfig.FilterMaskIdHigh=0xFFF0 << 5;
2024-02-14 05:08 AM
I am sure that the speeds are the same. It is 500kbps. My external clock is 25Mhz and the Can Bus feeds from the APB1 peripheral. APB1 peripheral is 42Mhz. I want to monitor just stm32. I send a 1 bit data from analayzer and I want to read the data on my stm32 in live expression. Here is a screenshot. You are true about the filter ı forgot the edit filters but yeah unrelated. And I attached a more simple code. The purpose of this program is receiving data from analyzer and observing in live expression. By the way, I am sure that the analyzer is working. Because I received many messages with analyzer from a device that transmit can bus message. and as I said My can bus system is working in normal mode with two stm32 boards
2024-02-14 05:48 AM
By the way, I am sure that the analyzer is working. Because I received many messages with analyzer from a device that transmit can bus message.
Ok.. you received messages on the analyzer with another device but did you try its transmit to another device in order to validate that its transmission is working well?
2024-02-14 05:50 AM
Also, what about termination resistors of 120 ohm?
2024-02-14 05:54 AM
I cant observe that the device receive data from analyzer. The device I am talking about just transmit data It doesnt receive data. On the other hand, I can not observe the data that I transmit from stm32 to analyzer. The two board communicate successfully and I want to observe the datas that in Can Bus line with analyzer but I cant observe neither. Should I use an extra HAL function or different an algorithm ?
2024-02-14 05:58 AM
I use MCP2551 can transciever IC so I used 60 ohm termination resistor on my stm32 can transciever circuit because In according to MCP2551 datasheet , the termination resistor should be 60 ohm in the recommended connection but There is a 120ohm resistor on the analyzer
2024-02-14 06:07 AM - edited 2024-02-14 06:10 AM
@maZers wrote:
I use MCP2551 can transciever IC so I used 60 ohm termination resistor on my stm32 can transciever circuit because In according to MCP2551 datasheet
Could you please share a screenshot of the part of the MCP2551 datasheet showing that the termination resistor should be at 60 Ohm? I suspect you're are referring to the Test circuit figures ..
because this is what was said in it:
2024-02-14 06:17 AM - edited 2024-02-14 06:21 AM
@maZers wrote:
I cant observe that the device receive data from analyzer. The device I am talking about just transmit data It doesnt receive data. On the other hand, I can not observe the data that I transmit from stm32 to analyzer. The two board communicate successfully and I want to observe the datas that in Can Bus line with analyzer but I cant observe neither. Should I use an extra HAL function or different an algorithm ?
If the communication between two STM32 boards is OK, I suspect something related to the analyzer. So you need also to validate its transmission. Is it capable to send messages? also check the HW, you need termination resistors of 120ohm on each side.
Regarding your implementation in the interrupt:
void CAN1_RX0_IRQHandler(void)
{
/* USER CODE BEGIN CAN1_RX0_IRQn 0 */
/* USER CODE END CAN1_RX0_IRQn 0 */
HAL_CAN_IRQHandler(&hcan1);
/* USER CODE BEGIN CAN1_RX0_IRQn 1 */
for(int i=0; i<pRxHeader.DLC;i++)
{
RxData[i];
}
HAL_CAN_GetRxMessage(&hcan1,CAN_RX_FIFO0,&pRxHeader,&RxData);
/* USER CODE END CAN1_RX0_IRQn 1 */
}
This is not the way we use the HAL.
You need to use Callbacks such as: HAL_CAN_RxFifo0MsgPendingCallback() and HAL_CAN_RxFifo1MsgPendingCallback()
2024-02-14 06:38 AM
Okey I will follow your tips and get feedback thank you so much