cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F105RC CAN recviev Message is overwritten

shen songyan
Associate II
Posted on November 01, 2017 at 07:29

Dear all,

I meet a problem is the messages what I receive via CAN bus are overwritten.

I check the datasheet,if FIFO lock function is �enabled�, the incoming message will be discarded.

0690X00000608ckQAA.png

But the value is also overwritten by next message. I don't know why ?

below is my Init code and receive interrupt code?

0690X00000608ocQAA.png0690X00000608ohQAA.png

#stm32f105-can-bus
7 REPLIES 7
Ben K
Senior III
Posted on November 01, 2017 at 15:32

If you want to keep the first received frame in the FIFO even after reading it, you shouldn't clear the RFOMx bit - I assume this is what CAN_FIFORelease() does in your context - as it advances the FIFO by discarding the first received element. This is not recommended however, storing the read frame in RAM for further processing is a much better solution.

Posted on November 01, 2017 at 15:39

The if/else construct is not helpful, multiple bits may reasonably be asserted, handle them all individually.

Perhaps if you remove messages quickly and queue them locally this won't become an issue. Also remember to keep iterating until ALL pending packets are removed, there can be between 1 and 3, and perhaps more if you are sluggish or traffic is heavy.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
shen songyan
Associate II
Posted on November 02, 2017 at 03:44

Yes, I set the breakpoints in this place. but never run into this location. So I'm not sure whether FIFO is full or overflow.

And how to judge remove message quickly?

Actually, I have to receive the messages and queue them locally, but it is still overwritten.

0690X00000608pBQAQ.png
Posted on November 02, 2017 at 03:03

Hi Ben,

How can I  modify the code? Because if I don't release the FIFO, I can not read next frame.

I just want to the new message don't overwrite the old message when I analyze the old message.

My analyze code is function : CAN1Action?canMessageData?;

I can modify it release FIFO after analyze:

CAN1Action(canMessageData);

CAN_FIFORelease();

Do you think it's ok?

0690X00000608p1QAA.png
Posted on November 02, 2017 at 03:59

I find why the if/else construct is not useful,  because I don't enable CAN_IT_FIFO, CAN_IT_FOVO.

I just Enable CAN_IT_FMP0

0690X00000608pGQAQ.png
Posted on November 02, 2017 at 14:41

I just want to the new message don't overwrite the old message when I analyze the old message.

I'm not sure I understand your problem anymore. You can't have both the old and the new received frame available at the end of the FIFO at the same time. You should read the FIFO contents and either process them in context, or store them each in RAM variables.

If by analyzing you mean processing of the frame data that has been read from the FIFO to a variable, then you most likely face a software problem that you need to resolve yourself.

Posted on November 06, 2017 at 03:27

HI Ben,

yes, I know that, problem is I set FRLM bit to ENABLE. So new received frame will be discarded.

I just analyze the old messages. I use CAN_Receive function to store the local variable. and in this function it also have release the FIFO.

0690X00000608rCQAQ.png

So? I don't know why it is overwritten by other messages?