AnsweredAssumed Answered

UART Problem - Can't write to UART0_THR

Question asked by NTan on May 26, 2013
Latest reply on Jun 3, 2013 by NTan

Good Day Everyone!


     I'm trying a simple code to send a character through UART. However, after debugging, I noticed that it fails to write to UART0_THR. This is the function which sends the character (from EE-347):


short UartPutc(unsigned char UartNum, char c)


    unsigned short UartMmrOffset = 0;

    switch (UartNum) {

        case 0: UartMmrOffset = UART0_MMR_OFFSET; break;

        case 1: UartMmrOffset = UART1_MMR_OFFSET; break;

        default: printf("%s(): UART%d is not available.\n",__func__,UartNum); return -1;



    volatile unsigned short *pUartLsr = (volatile unsigned short*) (UART0_LSR + UartMmrOffset);

    volatile unsigned short *pUartThr = (volatile unsigned short*) (UART0_THR + UartMmrOffset);


    while (!(*pUartLsr & THRE)) { /* wait */ } //when THRE is empty, write

    //*pUartThr = c;

    *pUART0_THR = c; // tried to put it directly in UART0_THR


     return 0;



Here's a screen shot of the Locals window and UART0 Registers (Figure 1):


So it successfully gets the value of 'c' but it fails to write during the *pUART0_THR = c;


When trying it in both the ADSP BF537 Blackfin family compiled simulator and ADSP BF537 ADSP-BF-5xx single processor simulator, it writes successfully. Here's the screenshot (Figure2)



Seeing this, I thought maybe there was something wrong with my clock value or baud rate ( since UART0_DLH and UART0_DLL are different when using simulator and the actual ez kit lite )? So I tried receiving a character using the uartputs function (modified it a bit though) instead of sending one . It was able to print in the console the characters I wrote in the hyperterminal.


I tried checking the silicon anomalies since my board is rev 0.2 and saw this: - 05000309 - Writing UART_THR While UART Clock Is Disabled Sends Erroneous Start Bit. It's work through is "Do not write to the UART_THR register when UCEN=0". However referring to Figure 1 above. UCEN bit of the UART0_GCTL register is set.


Another thing I don't understand is why both UART0_THR and UART0_RBR are written to (Refer to Figure 2). The same happens when I receive a character


I am using ADDS-BF537-EZLITE, Silicon rev 0.2. My switch settings are in default and I have removed the loop back jumper (J9). I am also using Visual DSP 5.0 ++ Update 10.1.


My code is also attached. The portion of the main code which reads characters is commented out.


Thank you and I would appreciate any help.  Sorry for the long message.