![ARTERY AT32F435 Series Reference Manual Download Page 405](http://html1.mh-extra.com/html/artery/at32f435-series/at32f435-series_reference-manual_2977592405.webp)
AT32F435/437
Series Reference Manual
2022.11.11
Page 405
Rev 2.03
20.6.6 Message reception
Register configuration
The CAN_RFIx, CAN_RFCx, CAN_RFDTLx and CAN_RFDTHx registers can be used by user
applications to obtain valid messages.
Message reception
The CAN controller boasts two FIFO with three levels to receive messages. FIFO rule is adopted. When
the message is received correctly and has passed the identifier filtering, it is regarded as a valid message
and is stored in the corresponding FIFO. The number of the received messages RFxMN[1: 0] will be
incremented by one whenever the receive FIFO receives a valid message. If a valid message is received
when RFxMN[1: 0]=3, the controller will select either to overwrite the previous messages or discard the
new incoming message through the MDRSEL bit in the CAN_MCTRL register.
In the meantime, when the user reads a frame of message and the RFxR is set in the CAN_RFx register,
one FIFO mailbox is released, and RFxMN[1: 0] bit is decremented by one in the CAN_RFx register.
Receive FIFO status
RFxMN[1: 0], RFxFF and RFxOF bits in the RFx register are used to indicate receive FIFO status.
RFxMN[1: 0]: indicates the number of valid messages stored in the FIFOx.
RFxFF: indicates that three valid messages are stored in the FIFOx (i.e. the three mailboxes are full),
as shown in (c) of Figure 20-13.
RFxOF: indicates that a new valid message has been received while the FIFOx is full, as shown in (d)
of Figure 20-13.
Figure 20-13
Receive FIFO status
Address
0
Address
1
Read
Addr
Write
Addr
(
a
)
Receive a valid frame
(
b
)
Receive a valid frame
(
c
)
Receive a valid frame
(
d
)
Receive a valid frame
(
e
)
Release a frame
(
f
)
Release a frame
Address
2
Address
0
Address
1
Address
2
Address
0
Address
1
Address
2
Address
0
Address
1
Address
2
Address
0
Address
1
Address
2
Address
0
Address
1
Address
2
Read
Addr
Read
Addr
Read
Addr
Read
Addr
Read
Addr
Write
Addr
Write
Addr
Write
Addr
Write
Addr
Write
Addr
20.6.7 Error management
The status of CAN nodes is indicated by the receive error counter (TEC) and transmit error counter
(REC) bits in the CAN_ESTS register. In the meantime, the ETR[2: 0] bit in the CAN_ESTS register is
used to record the last error source, and the corresponding interrupts will be generated when the
CAN_INTEN register is enabled.
Error active flag: When both TEC and REC are lower than 128, the system is in the error active
state. An error active flag is set when an error is detected.
Error passive flag: When either TEC or REC is greater than 127, the system is in the error passive
state. An error passive flag is set when an error is detected.
Bus-off state: The bus-off state is entered when TEC is greater than 255. In this state, it is impossible
to transmit and receive messages. The CAN resumes from bus-off state in two ways:
Option 1: When AEBOEN=0 in the CAN_MCTRL register, in communication mode, the software
requests to enter Frozen mode and exit Frozen mode, and CAN will then resume from bus-off state
after 128 occurrences of 11 consecutive recessive bits have been detected on the CAN RX pin.
Option 2: When AEBOEN=1 in the CAN_MCTRL register, the CAN will resume from bus-off state
automatically after 128 occurrences of 11 consecutive recessive bits have been detected on the CAN
RX pin