Hi,
I'm trying to get UART working on UCD3138A64OEVM-662 eval board. I've got "partial success", please help me get to the "full success" - I bet the problem is something "stupid".
This is how I initialize UART:
#define UARTREGS Uart1Regs
int uart_init(unsigned int baudrate)
{
const Uint32 brval = (15625000 / 8 + baudrate / 2) / baudrate - 1;
UARTREGS.UARTCTRL0.bit.SYNC_MODE = 1; //asynchronous
UARTREGS.UARTCTRL0.bit.DATA_SIZE = 8 - 1; //8 bit payload
UARTREGS.UARTLBAUD.bit.BAUD_DIV_L = (brval >> 0) & 0xff;
UARTREGS.UARTMBAUD.bit.BAUD_DIV_M = (brval >> 8) & 0xff;
UARTREGS.UARTHBAUD.bit.BAUD_DIV_H = (brval >> 16) & 0xff;
MiscAnalogRegs.CLKGATECTRL.bit.SCI1_CLK_EN = 1;
UARTREGS.UARTCTRL3.bit.SW_RESET = 1;
UARTREGS.UARTCTRL3.bit.SW_RESET = 0;
UARTREGS.UARTRXST.bit.RX_ENA = 1;
UARTREGS.UARTTXST.bit.TX_ENA = 1;
UARTREGS.UARTTXST.bit.TX_WAKE = 1;
UARTREGS.UARTIOCTRLRX.bit.IO_FUNC = 1; //UART RX
UARTREGS.UARTIOCTRLTX.bit.IO_FUNC = 1; //UART TX
return 0; //so far ignored
}
sending data:
#define tx_rdy() UARTREGS.UARTTXST.bit.TX_RDY
#define tx_send(b) (UARTREGS.UARTTXBUF.all = (b))
int uart_try_send(int d)
{
if( !tx_rdy() ) return 0;
tx_send(d);
return 1;
}
int uart_send(const char string[], const unsigned int len)
{
unsigned int i;
for( i = 0 ; i < len ; ++i ) { while( !uart_try_send(string[i]) ); }
return len;
}
and in the main it goes:
const char hello_text[] = "It is me!\n";
uart_init(9600);
uart_send(hello_text, 10);
this is done before the main loop which calls pmbus_handler. The program does nothing more.
I build it using Code Composer 7 under Windows and use UCD3xxx GUI to program and debug.
The result is that TX line goes high (idle) after entering program mode, and becomes low again after entering ROM mode, what partly is the expected behaviour (thus "partial success").
But my oscilloscope shows no transmission from the IC.
The debugger in the UCD3xxx GUI says that the TX buffer contains the last sent character of hello_text, ie. '\n' (code 0x0a).
The TX_RDY flag is set to 1.
UART does not receive anything - RX_RDY remains 0 and RX buffer remains unchanged.
This looks like something was preventing the output from / input to UART - are there any other registers used to configure pins?
I've connected the oscilloscope to J25, pin 3. For reception on PC I've put on a jumper at pins 2 & 3.
For reception at UART I've put on a jumper on J23, pins 2 & 3.
For communication with a PC I'm using an USB-to-RS232 converter (but this only "confirms" the no-result shown by the oscilloscope).
The Fault3 line is pulled LOW (this is the "backdoor" from training labs).
Best regards,
Adam