GD32A50x User Manual
636
reset or system reset, so CAN will automatically enters Inactive mode for configuration
of CAN registers.
Service the flags in CAN_STAT register
Read the Rx mailbox or Rx FIFO descriptor contents, clear the corresponding asserted
flag bit in CAN_STAT register, then read the CAN_TIMER register at last for a complete
flag bit service. If Rx FIFO is enabled, do a clearing FIFO operation by setting MS0 bit in
CAN_STAT register to 1. Also clear the asserted flags by Tx mailboxes.
Initialize the physical memory space for mailbox and Rx FIFO descriptors
Configure memory space for mailbox and Rx FIFO descriptors totally by MSZ[4:0] bits in
CAN_CTL0 register.
Configure the communication parameters
1) Configure the CAN nominal bit rate by PTS[5:0] bits, PBS1[4:0] bits, PBS2[4:0] bits,
SJW[4:0] bits and BAUDPSC[9:0] bits in CAN_BT register.
2) Configure bit sampling mode by BSPMOD bit in CAN_CTL1 register if needed.
3) Configure PREEN bit and EFDIS bit for bus integration state if needed.
Configure the control parameters for transmission
1) Configure arbitration priority by MTO bit in CAN_CTL1 register and LAPRIOEN bit in
CAN_CTL0 register.
2) Configure arbitration start delay by ASD[4:0] bits of CAN_CTL2 register if needed.
3) Enable transmission abort function for Tx mailbox descriptor configuration by MST bit
in CAN_CTL0 register.
Configure the control parameters for reception
1) Choose whether use Rx FIFO and Rx FIFO DMA for reception or not by RFEN bit and
DMAEN bit in CAN_CTL0 register.
2) Configure Rx private filter & Rx mailbox queue feature by RPFQEN bit in CAN_CTL0
register.
3) Configure receive filter related parameters by RFO bit, RRFRMS bit and
IDERTR_RMF bit of CAN_CTL2 register.
4) Configure filter data of the Rx mailbox and Rx FIFO by CAN_RMPUBF,
CAN_RFIFOPUBF and CAN_RFIFOMPFx (x = 0..31) registers. If Rx FIFO is enabled,
configure Rx FIFO ID filter table element format by FS[1:0] bits of CAN_CTL0 register,
configure Rx FIFO ID filter table element number by RFFN[3:0] bits of CAN_CTL2
register.
If CAN FD operation is needed
1) Select CAN FD operation protocol by ISO bit in CAN_CTL2 regitser.
2) Enable CAN FD operation by FDEN bit in CAN_CTL0 register.
3) Initialize the mailbox data size by MDSZ[1:0] bits of CAN_FDCTL register.
4) Configure CAN FD related transmitter delay compensation feature by TDCEN bit and
TDCO[4:0] bits of CAN_FDCTL register if needed.
5) Configure the CAN data bit rate by DPTS[4:0] bits, DPBS1[2:0] bits, DPBS2[2:0] bits
DSJW[2:0] bits and DBAUDPSC[9:0] bits in CAN_FDBT register.
Configure interrupts
Enable the needed interrupts in CAN_CTL0, CAN_CTL1, CAN_CTL2 and CAN_INTEN
registers.