2024-06-10 12:27 PM
Hello everyone. I am working on CAN communication with STM32F429I-Disc1 with TJA1050 transceiver. Standard communication works more than fine. What I would like to do next is to interrupt communication while CAN message with certain ID is present on bus. In other words I would like to detect while new message is started to be send, and after ID field I would like to send e.g. 20 0s (dominant bits) on the bus. HAL_CAN_RxFifo0MsgPendingCallback and HAL_CAN_GetRxMessage give access to complete frames. I need deeper and faster solution. Here are my questions:
1) Is there a way to solve my task with existing HAL libraries?
2) Where callback from HAL_CAN_RxFifo0MsgPendingCallback CAN interupt is done? Is it after complete message is received (and validated by crc check) or just after SOF bit received on the bus?
Thank you in advance for your help.
2024-06-20 07:10 AM - edited 2024-06-20 07:10 AM
Hello @kingston
Please find below the answers for your questions.
1) Is there a way to solve my task with existing HAL libraries?
>>Unfortunately, with the existing HAL, there is no way to detect while new message is started to be send.
2) Where callback from HAL_CAN_RxFifo0MsgPendingCallback CAN interupt is done? Is it after complete message is received (and validated by crc check) or just after SOF bit received on the bus?
>>The callback HAL_CAN_RxFifo0MsgPendingCallback is triggered after a complete message is received and stored in the Rx FIFO 0.
2024-06-20 08:14 AM - edited 2024-06-20 10:10 AM
Hello @kingston ,
What I would like to do next is to interrupt communication while CAN message with certain ID is present on bus. In other words I would like to detect while new message is started to be send
If by this you mean you need to detect a CAN message you are transmitting with a certain ID on the bus. I don't this is possible. May be you can detect this with EXTI connected to the CAN_TX pin to detect the SOF, which is not easy to implement (and with a specific ID!) but good luck :).
2) Where callback from HAL_CAN_RxFifo0MsgPendingCallback CAN interupt is done? Is it after complete message is received (and validated by crc check) or just after SOF bit received on the bus?
The callback is called after a CAN message has passed all the frame form check (bit form, frame format, CRC check etc), passed the filter you already configured and finally (as stated by @Saket_Om) be available in the RxFIFO.
2024-06-20 10:58 PM
HI, I've already figured it out that how to detect start of transmission of every CAN frame. I am triggering timer from external source gpio connected with CAN RX and set on falling edge. This way I am detecting every SOF.
At first I am waiting for 2s idly from trigger to interruption from timer CH1 event to set led. After next 2s led is reset. This works fine, so the idea is correct, but when I am setting timer Ch1 to (1/500.000)*15s and callback after (1/500.000)*30s I can see no difference in communication. I guess that code is not fast enough to perform such fast actions. Unfortunately I do not have scope or logic analyzer to verify exact bus states.