This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

UCD3138A: Questions about UART initialization

Part Number: UCD3138A
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:

  1. Why it implements a software reset after configuring other control register by setting Uart0Regs.UARTCTRL3.bit.SW_RESET = 1?

  2. Why there is always a “ Uart0Regs.UARTTXBUF.all = ' '; ” at the end of initialization?

  3. Will RXRDY flag be cleared by an UART software reset?

  4. 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

  • Dana,


    Why it implements a software reset after configuring other control register by setting Uart0Regs.UARTCTRL3.bit.SW_RESET = 1?

    --- The software reset is done to stop running the UART with initial BAUD rate value and start using the new value .

    2.Why there is always a “ Uart0Regs.UARTTXBUF.all = ' '; ” at the end of initialization?
    --- its not necessary . but this will be needed if UART TX interrupt is used.

    3.Will RXRDY flag be cleared by an UART software reset?
    ----Yes.

    4.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.

    --- Yes, but we need to stop clearing the bits , hence a zero is written afterwards.

    Thanks,
    Sanatan
  • Sanatan,

    Thanks a lot!!! It does help me to understand the UART initialization.