AnsweredAssumed Answered

BF538F EZ KIT UART

Question asked by theaman24 on Aug 2, 2011
Latest reply on Aug 5, 2011 by Andreas

Hi,

 

I'm trying to use UART0 to transmit from the BF358F EZ KIT to a PC with the following settings: 8 data bits, 1 stop bit, no parity, LSB first and a baud rate calculated as: baud rate = sclk/(16 * divisor), where 1< divisor < 65536. 

 

I've gone through the hardware reference manual and found the UART registers and what i thought i needed to set each to (code is shown at the bottom of this post).  One confusing part for me was the DLAB bit under UARTx_LCR.  The manual says setting it to 1 enables access to UARTx_DLL and DLH, while setting it to 0 enables access to THR, RBR, and IER.  In my code i initally set it to 1 and then set the DLL and DLH registers (which control the divisor to set the baud rate).  Then later i set DLAB to 0 so that i can write to the THR register to transmit.  Am i doing this correctly?

 

Another possible problem for me could be on the EZ KIT.  I have a USB to RS232 connector to go to my computer (with hyperterminal) from the EZ KIT.  SW4 controls the connections to the RS232 header on the EZ KIT, shown below in a screenshot from the ADSP-BF538F EZ-KIT Lite Evaluation System Manual. 

http://i.imgur.com/Kfyze.jpg

From here it looks like TX0 does not depend on SW4, and if i want to recieve over UART i would need SW4 pin 2 to be ON to send RX0 through to the RS232 header.  And for my application the others shouldnt matter (I currently have all of them on except for pin 4).  Is this right?

 

Or could i be missing some #include file for UART?

 

I dont see anything on hyperterminal when I run this code, and I'm not sure why.  Thanks for the help!

 

 

Code:

 

#include <stdlib.h>
#include <services/services.h>
#include <cdefBF538.h>
#include <ccblkfn.h>
#include <sys\exception.h>
#include <stdio.h>
int main( void )
{
  /* UART initializing */
   *pUART0_LCR = 0x0083;   //enable access to DLL,DLH; also sets 8 data bits,1 stop bit, no parity
  /* divisor latch registers to set baud rate - 54 for 115200 at 100MHz clk */
   *pUART0_DLL = 54;
   *pUART0_DLH = 0;
   *pUART0_MCR = 0x0000;  //modem control set to 0 - loopback disabled
    *pUART0_GCTL = 0x0001; //enable uart clocks
   *pUART0_LCR = 0x0003; //enable access to THR,RBR,IER; also sets 8 data bits,1 stop bit, no parity
   while(1)
   {
      *pUART0_THR = 123; //transmit 123
      while(!(*pUART0_LSR & 0x0020)); //wait for empty THR (transmission complete)
   }
}

Outcomes