AnsweredAssumed Answered

MPC5748G - Flexcan individual mask initialisation

Question asked by Jonathan L on Dec 10, 2018
Latest reply on Dec 12, 2018 by Jonathan L

Hello NXP,

 

I would like some help to understand something about flexcan individual mask.

 

I recently run into a bug where individual mask behavior was very strange.

 

For the background :

 

- The code I used did not initialised the individual mask before reception. I know that it is recommended by the RM but this code forgot to do it.
And actually the code and individual masks worked like a charm during several months without any initialisation.

 

But then very recently it suddenly stops to work (without any change on the can filter part of the code, but other function like gpio adc uart were added).
And then the individual mask seems to take the value of some frame ID that were already running on the CAN bus before I set the filter + mask.

 

So there is a CAN bus already alive, then I connect my MPC5748G on it (reception not active, all MB set as inactive at this point).
Then I set my filter @ 0x7E8 and mask @ 0xFFFFFFFF (in freeze mode) and finally activate reception interrupt.
At this point, I'm receiving other ID than the 0x7E8 one.

 

After understanding that individual mask was mocking me, I read again the RM and found :

 

"CAN_RXIMR registers can only be accessed by the CPU while the module is in Freeze
mode, otherwise, they are blocked by hardware. These registers are not affected by reset.
They are located in RAM and must be explicitly initialized prior to any reception."

 

I made some research and found another post of the nxp community forum that shows some initialisation :

 

CAN_0.RXIMR[8].R = 0xffffffff;   
CAN_0.RXIMR[9].R = 0xffffffff;   
CAN_0.RXIMR[10].R = 0xffffffff;   
CAN_0.RXIMR[11].R = 0xffffffff;   
CAN_0.RXIMR[12].R = 0xffffffff;   

 

So I adapted to my code, now RXIMR are initialised and the filter/mask seems to work again.

 

One major detail : this problem was IMPOSSIBLE to reproduce when the code runned with debugger,
it pop up only when running from flash without any debbugger like in the real field.

 

So the problem seems to be solved but here my real questions :

 

I understand that individual mask are located in RAM. But why should it be initialised before using it ?
Actually, since I write my target mask (which is also 0xFFFFFFFFF) inside, the value should be correct.
I thought all RAM was initialized with startup code.

 

I means, what is difference between
1) initialising the area and then put a desired value afterwards
2) or just putting desired value when communication is needed.

 


Other question :
How can it be that code without any initialisation worked well during months ?
And why it's not possible to reproduce the problem with the debugger ?

 

I really hope someone could explain me. Maybe it's stupid question but at least I would learn something.

 

Thanks in advance
Best regards.

Outcomes