Other Parts Discussed in Thread: UCD3138
Dear TI guys,
I have some questions about UART. Below codes is the Init demo code for UART.
My questions are:
-
Why it implements a software reset after configuring other control register by setting Uart0Regs.UARTCTRL3.bit.SW_RESET = 1?
-
Why there is always a “ Uart0Regs.UARTTXBUF.all = ' '; ” at the end of initialization?
-
Will RXRDY flag be cleared by an UART software reset?
-
Why it writes 0 to UARTINTST after writing 0xff to UARTINTST? According to Datasheet statement (shows below), It just have to write 1 to the bits to clear the flags.
R/C- means that bit can be read or cleared; each of the bits except RXERR and BUS BUSY can be cleared by writing a 1 to the bit. (Page 430, UCD3138 Digital Power Supply Controller Technical Reference Manual)
Uart0Regs.UARTCTRL3.bit.SW_RESET = 0; //software reset while initializing UART
Uart0Regs.UARTCTRL0.bit.DATA_SIZE = 7; //8 bits
Uart0Regs.UARTCTRL0.bit.STOP = 1; //2 stop bits
Uart0Regs.UARTCTRL0.bit.SYNC_MODE = 1; //asynchronous mode
Uart0Regs.UARTHBAUD.bit.BAUD_DIV_H = 0;
Uart0Regs.UARTMBAUD.bit.BAUD_DIV_M = 0;
Uart0Regs.UARTLBAUD.bit.BAUD_DIV_L = 49; //for 38400 //47 for control board, 44 for open loop
Uart0Regs.UARTRXST.bit.RX_ENA = 1 ;//enable RX
Uart0Regs.UARTTXST.bit.TX_ENA = 1;//enable TX
Uart0Regs.UARTINTST.all = 0xff; //these two statements are supposed to clear the status bits
Uart0Regs.UARTINTST.all = 0;
rx_byte = Uart1Regs.UARTRXBUF.bit.RXDAT; //clear RXRDY flag
Uart0Regs.UARTIOCTRLTX.bit.IO_FUNC = 1; //enable transmit pin
Uart0Regs.UARTIOCTRLRX.bit.IO_FUNC = 1; //enable receive pin
Uart0Regs.UARTCTRL3.bit.CLOCK = 1; //internal clock select;
Uart0Regs.UARTCTRL3.bit.SW_RESET = 1; //software reset released UART init done?
Uart0Regs.UARTIOCTRLSCLK.bit.IO_FUNC = 0; //disable external clock for UART.
Uart0Regs.UARTTXBUF.all = ' '; //put out a byte to get things started.
Looking forward to your reply
Best Regards
Dana Huang