5. Usage
5.1. Receive Messages
Figure 5.1 shows an example flowchart of message reception using the CAN receive completion interrupt
(INTCANRXD).
Setup a mailbox for
message reception
Disable mailbox:
set [CANMC]<MCn> to "0"
Configure mailbox for
reception:
set [CANMC]<MDn> to "1"
Setup mailbox identifier
and [CANMBnID]<IDE> bit for
Standard ID or extended ID
Set
[CANMBnID]<GAME_LAME>
of the mailbox if necessary
Setup [CANLAM]<LAM> /
[CANGAM]<GAM>
If necessary
Enable interrupts:
set [CANMBIM]<MBIMn>
to
1
"
"
Enable mailbox:
set [CANMC]<MCn> to "1"
End of setup
It is also possible to use polling instead of receive interrupts. In this case, the "waiting for INTCANRXD" in
above flowchart must be replaced by polling [CANRMP]. Further, enabling interrupts and clearing [CANMBRIF]
must be removed from the flow.
2018-10-30
Yes
New setup for
the mailbox?
Check [CANRMP]<RMPn> or
Data has become inconsistent
Yes
Figure 5.1 Flowchart of Message Reception
50 / 54
Receiving messages
No
No
Wait for
INTCANRXD
Yes
[CANMBRIF]<MBRIFn>
to determine the mailbox
Read out the mailbox
No
[CANRML]<RMLn> = 1?
Yes
reading it out!
Clear [CANRMP]<RMPn>,
this clears also <RMLn>
Read Out Mailbox again
No
[CANRML]<RMLn> = 1?
TXZ Family
CAN Controller
Clear [CANMBRIF]<MBRIFn>
and
return from interrupt
service routine
Special user tasks
Clear [CANRMP]<RMPn>,
this clears also
[CANRML]<RMLn>
Rev. 1.1