UART example code BF533

Hi i am testing UART module of ADSP BF533 on board EZ Lite BF533. Could you give me an example code, which configure register to test UART module on the board. I have read the example in folder VisualDSP 5.1.2\Blackfin\Example, but all example is using adi library (which i do not use). I need an example code which configure directly value on UART register of BF533. 

Thank you!

  • Thank you, i have change it and my code run well. But there is a small issue as below:

    When i send an uppercase character, it is transmit good but when i send a lowercase character, it is wrong.

    My code in file uart.c is below:

    #include "uart_test.h"

    void initUART (void)
    {
    *pUART_GCTL = UCEN; // enable clock UART
    //*pUART_LCR = DLAB;
    *pUART_LCR = 0x0080;// Enable access UART DLL DLH

    // set baud rate = 9600
    *pUART_DLL = 0x60;
    *pUART_DLH = 0x01;
    *pUART_LCR = WLS(8); // set data 8 bit word long

    *pUART_IER = 0x0000; // disable clock, using polling for transmit
    asm("ssync;");
    }

    void putc (char c)
    {
    while (!(*pUART_LSR & THRE)) {};
    *pUART_THR = c;
    }

    And in my main is below:

    #include <sys/platform.h>
    #include "adi_initialize.h"
    #include "uart_test.h"

    char __argv_string[] = "";

    int main(int argc, char *argv[])
    {
    adi_initComponents();
    int i;
    i = 0;
    char *s = "BBBBAAAAACaaa bbbb BF533 is talking";
    initUART();
    while (s[i] != NULL) {
    putc(s[i++]);
    }
    }

  • 0
    •  Analog Employees 
    on Apr 27, 2020 5:49 AM 10 months ago in reply to Thanh Nguyen

    Hi,

    Sorry for the delay in response.

    Were you able to get going?

    1) Can you try with different baud rates?  What is the Sclk frequency?
    2) Why the UART baud registers are configured to 0x0160? Can you try with the value 651(0x028B) for 9600 baud rate?
    3) Please refer section "UART_DLL and UART_DLH Registers" and "Table 13-1" in BF533 Hrm page no: 587.
        www.analog.com/.../ADSP-BF533_hwr_rev3.6.pdf
    4) When using 0x0160 as divider value, we are getting 17,755 as baud rate. Are you using 17,755 as baud rate?

    Regards,
    Anand Selvaraj.

  • I set the UART buad to 0x0160 because i think the SCLK frequency ís 54 MHh and use calculator: 54 MHz/16/9600 = 352 . I am not sure about SCLK frequency of the board. My board is EZ-Lite Kit BF533. I do not change any thing of clock register, i just use the default clock of the board. I have tried with the value 651(0x28B) but it still not work. Could you give me the SCLK frquency defauld of the board ?