![GigaDevice Semiconductor GD32A50 Series Скачать руководство пользователя страница 613](http://html.mh-extra.com/html/gigadevice-semiconductor/gd32a50-series/gd32a50-series_user-manual_2225782613.webp)
GD32A50x User Manual
613
2.
If the mailbox is active (either Tx or Rx), inactivate the mailbox by method described in
, when Tx mailbox inactivation is
performed, do the following steps, when Rx mailbox inactivation is performed, go to step
6. While if the mailbox is inactive (either Tx or Rx), go to step 6.
3.
Poll the the corresponding MSx bit in CAN_STAT register to be set, or by the interrupt
when MIEx bit in CAN_INTEN register is set.
4.
Read back the CODE field to get the state of the mailbox (aborted, or transmitted).
5.
Clear the corresponding flag MSx in the CAN_STAT register.
6.
Write mailbox ID field (plus the mailbox PRIO field if LAPRIOEN bit in CAN_CTL0 register
is set to 1) of the MDES1 word.
7.
Write payload data bytes in mailbox DATA field of MDESx (x = 2..17) word.
8.
Configure the mailbox IDE, RTR, FDF, BRS, ESI, and DLC field to MDES0 word.
9.
Activate the mailbox to transmit the frame by setting mailbox CODE field to 0b1100.
When the mailbox is activated, it participates in the arbitration process and is eventually
transmitted according to its priority. When the mailbox payload size is less than the
mailbox DLC value, CAN adds the necessary number of bytes with constant 0xCC to
meet the expected DLC.
Upon a successful transmission, the CODE field is automatically updated, and the
TIMESTAMP field is automatically updated with the value of the free running counter; the
CRC registers (CAN_CRCC and CAN_CRCCFD) are updated, and the corresponding flag
MSx in the CAN_STAT register is set, if the interrupt enable bit MIEx in CAN_INTEN register
is set, an interrupt will be generated.
Arbitration process
When more than one Tx mailbox is pending, the arbitration process which searching from the
lowest number mailbox to the higher ones will give the transmission order. The arbitration
algorithm is controlled by the MTO bit in CAN_CTL1 register.
The arbitration process starts when matching one of the following situations:
The CRC field on CAN bus: number of ASD[4:0] (in CAN_CTL2 register) CAN bits delay
after the first bit of the CRC field.
The Error or Overload Delimiter field on CAN bus.
CAN bus is recovering from Bus Off state: number of ASD[4:0] (in CAN_CTL2 register)
CAN bits delay after the counter TECNT[7:0] counted to 124. Recovering from Bus Off
state needs 128 times of 11 continuous recessive bits, which is counted by TECNT[7:0]
in CAN_ERR0 register.
Exit from Inactive mode, or power saving mode (including CAN_Disable mode and
Pretended Networking mode).
Rewrite of MDES0 word of arbitration winner (temporary winner or final winner).
Rewrite to MDES0 word of the scanned mailbox (arbitration is on-going): if no arbitration
winner is found when scan finished, arbitration will restart at soon; otherwise, the
arbitration process is finished.
Write to MDES0 word of a mailbox: when no arbitration is processing, and no arbitration