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.

AM335x: What are the registers needed to configure UART2

Hi,

                  Iam trying to write a simple function in am335x beagle bone gel file to make UART2 work, but i am not getting the characters which i have sent from  THR buffer, i need to know which are all registers have to set or what should be the basic configuration for UART. Below are the changes i made .

WR_MEM_32(SPI0_D0, 0x01);/*txd*/

WR_MEM_32(SPI0_SCLK, 0x21);/*rxd*/

WR_MEM_32(UART2_LCR, 0x03);

WR_MEM_32((UART2_BASE_ADDR + THR), 0x29);

i have defined these register's address at first as in the datasheet. please give any suggestions..

  • Hello,
    I will move your question to the Sitara forums, where the experts there can help you best.

    Thanks
    ki
  • Here is the UART programming sequence as implemented in Starterware: processors.wiki.ti.com/.../CIR
    You will also find information in section 19.4.1 of the AM335x TRM Rev. M.
  • Hi, 

    Iam facing problems as follows

    1) If i write something in DLL and DLH register by setting LCR to BFh that is reflecting in the THR and RHR.

    2) If i switch the operation mode to normal that time i can't write anything in THR.

    3)As in the data sheet in the operation mode A and B the module disabled these are only for initialization. According to this after initialization i changed to operationi mode to normal, that time iam not able to write and receive.

    4) It is also mentioned that to enable fifo DLL and DLH should be cleared to 0, how it ll be 0..? If write write something in one address it is reflecting to other registter address too. How to avoid this?  

  • Check that all address offsets are correct in your register definitions. I cannot comment what's wrong from your description alone.
  • Hi,

    These are i have defined ,

    #define UART2_BASE_ADDR (0x48024000) /*uart configuration*/
    #define UART2_THR (UART2_BASE_ADDR + 0x00)
    #define UART2_RHR (UART2_BASE_ADDR + 0x00)
    #define UART2_LCR (UART2_BASE_ADDR + 0xC)
    #define UART2_DLL (UART2_BASE_ADDR + 0x00)
    #define UART2_DLH (UART2_BASE_ADDR + 0x04)
    #define UART2_EFR (UART2_BASE_ADDR + 0x08)
    #define UART2_FCR (UART2_BASE_ADDR + 0x08)

    If i write to EFR that is reflecting to FCR, i need to know which are the basic configuration i have to for uart to work?
  • Hi this is function i have written in gel file..

    uart_enable()
    {
    UWORD32 i, j, k, num, *buf;
    GEL_TextOut("****uart_changes*****\n","Output",1,1,1);

    /*for UART2*/
    /*pin mux*/
    WR_MEM_32(SPI0_D0, 0x01);/*txd*/
    WR_MEM_32(SPI0_SCLK, 0x31);/*rxd*/

    /*clock enable and reg configuration*/
    WR_MEM_32(CM_PER_UART2_CLKCTRL, 0x02);

    WR_MEM_32(UART2_LCR, 0x89);/* enabled the latch*/
    WR_MEM_32(UART2_DLL, 0x38);/*for 9600 baudrate*/
    WR_MEM_32(UART2_DLH, 0x01);
    num =0;
    WR_MEM_32(UART2_LCR, 0x09);/*return back to normal opearation*/
    while(1) {
    num = num+1;
    WR_MEM_32(UART2_THR, (0x31 + num));/*writing to THR buffer*/
    for(k=0;k<10;k++)
    {
    for(j=0;j<100000;j++);

    }
    GEL_TextOut("****transmit*****\n","Output",1,1,1);

    }
    }

    When i return back to the normal mode , DLL , DHL, THR, RHR all the values are changing and not getting the any charaacters on pc minicom.
  • See TRM section 19.4.1.1.3 Protocol, Baud Rate, and Interrupt Settings. Note that all UART register should be written with 8-bit writes.