GD32A50x User Manual
205
0. Can invert input data by setting PINPL.
3.
Set the value of register MFCOM_TMCMPx as 0x00000F01, configure 8-bit transfer with
baud rate of divide by 4 of the MFCOM clock. Set TMCVALUE [15:8] = (number of bits x
2) - 1. Set TMCVALUE [7:0] = (baud rate divider / 2) - 1.
4.
Set
the
bits
TMOUT[1:0],
TMDEC[1:0],
TMRST[2:0],
TMSTOP[1:0],
TMDIS[2:0],TMEN[2:0] and TMSTART as 0b10, 0b00, 0b100,0b10, 0b010, 0b101 and
0b1 in register MFCOM_TMCFGx respectively,
configure start bit, stop bit, enable on pin
posedge and disable on compare. Enable resynchronization to received data with
TMOUT[1:0] = 0b10 and TMRST[2:0] = 0b100.
5.
Set the bits TRIGSEL[3:0], TRIGPL, TRIGSRC, TMPPL, and TMMOD[1:0] as 0b0010,
0b1, 0b1, 0b1, and 0b01 in register MFCOM_TMCTLx respectively, configure dual 8-bit
counter using inverted pin 0 input.
6.
Set the bits TMCVALUE[15:0], as 0xFFFF in register MFCOM_TMCMP(x+1) , and never
compare.
7.
Set the bits TMDEC[1:0], TMDIS[2:0], TMEN[2:0] as 0b11, 0b110, and 0b001 in register
MFCOM_TMCFG(x+1) respectively, enable on timer x enable and disable on trigger
falling edge. Decrement on trigger to ensure no compare.
8.
Set the bits TRIGSEL[3:0], TRIGSRC, TMPCFG, and TMMOD[1:0] as 0b0001, 0b1, 0b11,
and 0b11 in register MFCOM_TMCTL(x+1) respectively, configure 16-bit counter and
output on pin 1. Trigger is internal using shifter 0 flag.
9.
Set the bit SBUF[31:0] as data to receive in register MFCOM_SBUFx, received data can
be read from SBUFBYS[7:0], use the shifter status flag to indicate when data can be
read using interrupt or DMA request. Can support MSB first transfer by reading from
SBUFBIS[7:0] register instead.
SPI master
The SPI main mode uses two timers, two shifters, and four pins. Either CPHA=0 or CPHA=1
can be supported. For CPHA=1, the select can hold assertions over multiple transfers, and
the timer status flag is used to determine the end of the transfer. It also supports DMA
transport.
There is at least one clock cycle before the stop bit is transferred to the next one, the transport
buffer is written via the core or DMA to initiate each transport. The serial input data is set to 3
RCU_MFCOM clock cycles, and due to synchronization delays, the maximum baud rate is
the MFCOM clock frequency divided by 8.
SPI master (CPHA=0) configuration
1.
Keep the value of register MFCOM_SCFGx as default, start and stop bit disabled.
2.
Set the bits TMPL, SPCFG[1:0] and SMOD[1:0] as 0b1, 0b11 and 0b010 in register
MFCOM_SCTLx respectively, configure transmit using timer 0 on negedge of clock with
output data on pin0.
3.
Keep the value of register MFCOM_SCFG(x+1) as default, start and stop bit disabled.
4.
Set the bits SPSEL[2:0], and SMOD[1:0] as 0b001, and 0b01 in register
MFCOM_SCTL(x+1) respectively, configure receive using timer 0 on posedge of clock