> Flexcan loose remote frames.
Because you have to tighten up those loose frames :-)
> However we are NOT accessing the MB control word. We are simply writing to data byte 0.
You are writing to a shared resource.
You're doing so in a way that violates some basic design assumptions, and is not following the Reference Manual.
Which are that the whole message buffer is either owned by the hardware, and you're not allowed to touch any of it, or it is owned by you and isn't in use by the hardware.
This sort of thing happens all the time when there's a register that the user and hardware have to access.
The Silicon designers have to handle this by making the location dual-ported so it can support simultaneous access, or there has to be some "arbitration hardware" that decides who gets it.
Or in many cases, like this CAN controller and parts of Ethernet controllers, then the "lock" for part of the hardware is assumed to be set by some other operation. In this case, writing the Control/Status word.
Sometimes the hardware designer gets it very wrong and doesn't provide a workaround. For instance in the LCD Controller in the MCF5329, there an "MCF_LCDC_LISR" register that reports the current interrupts. It is a read-to-clear register, and it is only meant to be read immediately after an interrupt has happened. I was polling it to see when the next interrupt happened, and it didn't work sometimes. If the chip is trying to set a bit in that register on the same clock cycle that it is being read, the "read" wins and the bit-set fails completely.
TheMCF5235 Reference Manual states:
21.4.1 Transmit Process
The CPU prepares or changes an MB for transmission by executing the following steps:
1. Writing the control/status word to hold Tx MB inactive (CODE = 1000).
2. Writing the ID word.
3. Writing the data bytes.
4. Writing the control/status word (active CODE, LENGTH).
NOTE
The first and last steps are mandatory!
So you're not allowed to just "change a byte" when the MB is owned by the hardware. You have to force it inactive first.
I was worried that the "inactive/write/active" sequence might make the buffer miss a match (like you're getting now), but this seems to be handled properly. The following section says a message will "wait" until an MB is unlocked:
21.4.4 Matching Process
If the last matching MB is locked, then the new message
remains in the SMB, waiting for the MB to be unlocked (see Section 21.4.5.3, “Locking and
Releasing Message Buffers”).
If you still have problems, it might be possible to have TWO matching MBs (with the alternate data in them) and then "ping-pong" their activations, havving two of them enabled during the overlap. But it looks like "Inactivate/Write/Activate" should work.
Tom