2017-10-31 11:29 PM
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.
But the value is also overwritten by next message. I don't know why ?
below is my Init code and receive interrupt code?
#stm32f105-can-bus2017-11-01 07:32 AM
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.
2017-11-01 07:39 AM
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.
2017-11-01 07:44 PM
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.
2017-11-01 08:03 PM
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?
2017-11-01 08:59 PM
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
2017-11-02 07:41 AM
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.
2017-11-05 07:27 PM
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.
So? I don't know why it is overwritten by other messages?