AnsweredAssumed Answered

a problem in "Clocking the UART"  on P2010 SoC

Question asked by esode on Jun 14, 2013
Latest reply on Jun 20, 2013 by Marius Grigoras

Hello all,

 

I initialized p2010 by gdb and I wrote a .c code to configure the DUART by register level.

I checked that writing/reading on UART registers is working e.g. : I changed the SB bit of UARt Line Control Register(ULCR) and saw the

SOUT pin changing on the oscilloscope. Up to here, everything is ok. However, I try to write "A" character in a while loop and I look

at the SOUT pin, and it is always in high voltage; so UART is not sending anything. I guess UART cannot get its clock from

the platform bus(CCB), because changing divisor value doesn't affect test1(,which is dummy variable to count how many times "A" is sent).

I appreciate your any help. I wonder maybe to enable the UART clock.

 

Here is the my main.c function. It is very simple and readable:

 

 

/*  uart registers configuration - THE ADDRESSES   */

#define UART0_1  0x100 // 0x0 for UART0 and 0x100 for UART1

 

 

#define URBR_ADDR  (0xE0004500 + UART0_1) // read-only

#define UTHR_ADDR  (0xE0004500 + UART0_1) // Transmit Holding Register

#define UDLB_ADDR  (0xE0004500 + UART0_1) // Divisior LeastSignificant Byte Register

#define UIER_ADDR  (0xE0004501 + UART0_1)

#define UDMB_ADDR  (0xE0004501 + UART0_1) // Divisior MostSignificant Byte Register

#define UIIR_ADDR  (0xE0004502 + UART0_1) // read-only

#define UFCR_ADDR  (0xE0004502 + UART0_1)

#define UAFR_ADDR  (0xE0004502 + UART0_1)

#define ULCR_ADDR  (0xE0004503 + UART0_1) // Line Control Register

#define UMCR_ADDR  (0xE0004504 + UART0_1)

#define ULSR_ADDR  (0xE0004505 + UART0_1) // read-only

#define UMSR_ADDR  (0xE0004506 + UART0_1) // read-only

#define USCR_ADDR  (0xE0004507 + UART0_1)

#define UDSR_ADDR  (0xE0004510 + UART0_1) // read-only

 

 

/*  uart registers configuration - THE VALUES   */

#define ULCR_DLAB1 0x83    // the value for Line Control Register

#define ULCR_DLAB0 0x03    // the value for Line Control Register

 

 

unsigned int ulsr;

 

unsigned int test1;

unsigned int test2;

/***************************** MAIN ******************************************/

int main()

{  

  test1 = 1;

 

  *((char *)ULCR_ADDR) =  ULCR_DLAB1;

  *((char *)UDLB_ADDR) =  0x01;

  *((char *)UDMB_ADDR) =  0x10;

  *((char *)UAFR_ADDR) =  0x00;

 

  test1 = 2;

 

  *((char *)UMCR_ADDR) =  0x00;

  *((char *)USCR_ADDR) =  0x75;  // the value is not important

 

  test1 = 3;

 

  *((char *)ULCR_ADDR) =  ULCR_DLAB0;

  *((char *)UIER_ADDR) =  0x00;

  *((char *)UFCR_ADDR) =  0x00;

 

 

  test1 = 0;

  while(1)

  {

       ulsr = *((char *)ULSR_ADDR);

       if (   ulsr & 0x0020 )  // check the 'THRE' bit of ULSR

       {

            *((char *)UTHR_ADDR) =  0x41;  // send "A"    

            test1++;    

       }

       else

            test2++;

  }

 

  return 0;

}

 

 

 

Outcomes