FlexCAN RX Message Buffer Handling and BUSY State in MPC5674F

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FlexCAN RX Message Buffer Handling and BUSY State in MPC5674F

551 Views
mertk
Contributor IV

Hi all,

I am checking the IFLAG registers before reading the FlexCAN message buffers configured as RX. Should I also check whether the CODE field is in the BUSY state?

In the MPC5674FRM, the following information is given:

Upon reading the Control and Status word, if the BUSY bit is set in the Code field, then the CPU should defer the access to the MB until this bit is negated.

and

In summary: never do polling by reading directly the C/S word of the MBs. Instead, read the IFLAG registers.

Based on these statements, I am unsure how to detect that the CODE field has transitioned out of the BUSY state without polling the CODE field of the message buffers directly.

How should this be interpreted in practice?
Is checking the corresponding IFLAG sufficient to guarantee that the message buffer is safe to read?

Could you please suggest a reliable and recommended procedure for receiving messages using FlexCAN?

Looking forward to your insights.

Best regards,
Mert

Tags (3)
0 Kudos
Reply
1 Reply

319 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

you should wait for MB flag to be set. Then read the CS word, which also lock the MB. The MB lock prevents a new frame from being written into the message buffer when the CPU is reading it. If during this CS word read the BUSY flag will be set defer the access to the rest MB area until this bit is negated.

BR, Petr

 

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2302408%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EFlexCAN%20RX%20Message%20Buffer%20Handling%20and%20BUSY%20State%20in%20MPC5674F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2302408%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%20class%3D%22%22%3E%3CSPAN%3EHi%20all%2C%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22%22%3E%3CSPAN%3EI%20am%20checking%20the%20IFLAG%20registers%20before%20reading%20the%20FlexCAN%20message%20buffers%20configured%20as%20RX.%20Should%20I%20also%20check%20whether%20the%20CODE%20field%20is%20in%20the%20BUSY%20state%3F%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22%22%3E%3CSPAN%3EIn%20the%20%3C%2FSPAN%3E%3CSTRONG%3E%3CSPAN%3EMPC5674FRM%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSPAN%3E%2C%20the%20following%20information%20is%20given%3A%3C%2FSPAN%3E%3C%2FP%3E%3CBLOCKQUOTE%3E%3CP%20class%3D%22%22%3E%3CSPAN%3EUpon%20reading%20the%20Control%20and%20Status%20word%2C%20if%20the%20BUSY%20bit%20is%20set%20in%20the%20Code%20field%2C%20then%20the%20CPU%20should%20defer%20the%20access%20to%20the%20MB%20until%20this%20bit%20is%20negated.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FBLOCKQUOTE%3E%3CP%20class%3D%22%22%3E%3CSPAN%3Eand%3C%2FSPAN%3E%3C%2FP%3E%3CBLOCKQUOTE%3E%3CP%20class%3D%22%22%3E%3CSPAN%3EIn%20summary%3A%20never%20do%20polling%20by%20reading%20directly%20the%20C%2FS%20word%20of%20the%20MBs.%20Instead%2C%20read%20the%20IFLAG%20registers.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FBLOCKQUOTE%3E%3CP%20class%3D%22%22%3E%3CSPAN%3EBased%20on%20these%20statements%2C%20I%20am%20unsure%20how%20to%20detect%20that%20the%20CODE%20field%20has%20transitioned%20out%20of%20the%20BUSY%20state%20without%20polling%20the%20CODE%20field%20of%20the%20message%20buffers%20directly.%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22%22%3E%3CSPAN%3EHow%20should%20this%20be%20interpreted%20in%20practice%3F%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3EIs%20checking%20the%20corresponding%20IFLAG%20sufficient%20to%20guarantee%20that%20the%20message%20buffer%20is%20safe%20to%20read%3F%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22%22%3E%3CSPAN%3ECould%20you%20please%20suggest%20a%20reliable%20and%20recommended%20procedure%20for%20receiving%20messages%20using%20FlexCAN%3F%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22%22%3E%3CSPAN%3ELooking%20forward%20to%20your%20insights.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EBest%20regards%2C%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3EMert%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2346949%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20FlexCAN%20RX%20Message%20Buffer%20Handling%20and%20BUSY%20State%20in%20MPC5674F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2346949%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%2C%3C%2FP%3E%0A%3CP%3Eyou%20should%20wait%20for%20MB%20flag%20to%20be%20set.%20Then%20read%20the%20CS%20word%2C%20which%20also%20lock%20the%20MB.%20The%20MB%20lock%20prevents%20a%20new%20frame%20from%20being%20written%20into%20the%20message%20buffer%20when%20the%20CPU%20is%20reading%20it.%20If%20during%20this%20CS%20word%20read%20the%20BUSY%20flag%20will%20be%20set%26nbsp%3B%3CSPAN%3Edefer%20the%20access%20to%20the%20rest%20MB%20area%20until%20this%20bit%20is%20negated.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EBR%2C%20Petr%3C%2FSPAN%3E%3C%2FP%3E%0A%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E