Reply
Highlighted
Visitor
Posts: 3
Registered: ‎09-11-2015

OMAP-L138 UART2 doesn't work

Hi,

I have an Avnet Spartan-6/OMAP Co-Processing Development Kit. I'm trying connect with Console on PC using UART2 <-> USB.
The example program from OMAPL138_StarterWare_1_10_03_03 doesn't work. File uartEcho.c in attachment. The problem is that data which is writing to THR Register (Transimtter Holding Register) in reallity isn't write. I checked it with JTAG. THR register has always value 0x00.

Settings of the serial connection:

Bits per second = 115200

Data bits = 8

Parity = None

Stop bits = 1

Flow control = None

I worte the simple program that send data (0x44 hex) to THR Register in UART2:

#include "soc_OMAPL138.h"
#include "interrupt.h"
#include "evmOMAPL138.h"
#include "uartStdio.h"
#include "hw_types.h"
#include "uart.h"

//----------------------------------------------------------------------------
#define UART_CONSOLE_BASE (SOC_UART_2_REGS)
#define PSC_MDCTL_NEXT_ENABLE (0x00000003u)
//----------------------------------------------------------------------------
static void Delay(volatile unsigned int count);
//----------------------------------------------------------------------------
void main(void)
{
unsigned int status;
status = PSCModuleControl(SOC_PSC_1_REGS,13, 0, PSC_MDCTL_NEXT_ENABLE);
UARTPinMuxSetup(2, FALSE);

/* Enables the transmitter and receiver*/
/* Enable the Tx, Rx and the free running mode of operation. */
HWREG(UART_CONSOLE_BASE + UART_PWREMU_MGMT) = 0x00006003u;


/* Configuring the UART parameters*/
/* 8-bit work length, no parity, 1 stop bit. */
/* The UART module input frequency shall be 150MHz.*/
HWREG(UART_CONSOLE_BASE + UART_MDR) = 0x00000000u; // 16 x oversampling
// 150MHz/(16*115200) = 81,38 -> 81 -> 0x51 (hex)
HWREG(UART_CONSOLE_BASE + UART_DLL) = 0x00000051u;
HWREG(UART_CONSOLE_BASE + UART_DLH) = 0x00000000u;
// 8 bits, 1 STOP bit, no parity, no break control
// WLS=3,STB=0,PEN=0,EPS=0,SP=0,BC=0,DLAB=0
HWREG(UART_CONSOLE_BASE + UART_LCR) = 0x00000003u;

/* Enables FIFO mode for transmitter and receiver.*/
HWREG(UART_CONSOLE_BASE + UART_FCR) = 0x00000000u;
HWREG(UART_CONSOLE_BASE + UART_FCR) = 0x00000001u; // FIFOEN=1,RXCLR=0,TXCLR=0,DMAMODE1=0,RXFIFTL=0(1 byte)
HWREG(UART_CONSOLE_BASE + UART_FCR) |= 0x000000C1u; // FIFOEN=1,RXCLR=0,TXCLR=0,DMAMODE1=0,RXFIFTL=3(14 byte)

unsigned int txEmpty;
txEmpty = (UART_THR_TSR_EMPTY | UART_THR_EMPTY);
do
{
while (txEmpty != (HWREG(UART_CONSOLE_BASE + UART_LSR) & txEmpty));
HWREG(UART_CONSOLE_BASE + UART_THR) = 0x44u;
Delay(0xFFFF);
}
while(1);
}
//----------------------------------------------------------------------------
void Delay(volatile unsigned int count)
{
while(count--);
}
/****************************** End of file **********************************/

I have still the same problem - it doesn't work. I can't write data to THR register.
Does anyone has an idea what is the problem?
Thanks.
Lukasz.