Ok,
I just spent 2 days hammering away at getting UART1 to put out a signal on the TI LM3S9B92-B eval board.
The sample code called hello.c talks to UART0 and works fine.
If you try to switch to UART1 or UART2 it does not work.
SO I extracted the driverlib calls out to an easily switchable linear piece of code, like this...
(The blog post code mangles the C code a bit. The for loops are munged.)
int
main(void)
{
int uartIdx = 1;
volatile unsigned long i;
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
if(uartIdx == 0)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200,
(UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_ONE |
UART_CONFIG_WLEN_8));
}
else
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
GPIOPinTypeUART(GPIO_PORTD_BASE, GPIO_PIN_2 | GPIO_PIN_3);
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
UARTConfigSetExpClk(UART1_BASE, ROM_SysCtlClockGet(), 115200,
(UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_ONE |
UART_CONFIG_WLEN_8));
}
for(i=0; i<100000;>
{
}
//
while(1)
{
if(uartIdx == 0)
{
UARTCharPut(UART0_BASE, 'K');
}
else
{
UARTCharPut(UART1_BASE, 'K');
}
for(i=0; i<100000; i =" i"> {
}
}
}
But UART1 was stubbornly silent.
Here is the corrected code, notice that I have to explicitly set the pins up...
int
main(void)
{
int uartIdx = 1;
volatile unsigned long i;
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
if(uartIdx == 0)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200,
(UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_ONE |
UART_CONFIG_WLEN_8));
}
else
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
GPIOPinTypeUART(GPIO_PORTD_BASE, GPIO_PIN_2 | GPIO_PIN_3);
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
UARTConfigSetExpClk(UART1_BASE, ROM_SysCtlClockGet(), 115200,
(UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_ONE |
UART_CONFIG_WLEN_8));
GPIOPinConfigure(GPIO_PD2_U1RX);
GPIOPinConfigure(GPIO_PD3_U1TX);
}
for(i=0; i<100000;i++>
{
}
//
while(1)
{
if(uartIdx == 0)
{
UARTCharPut(UART0_BASE, 'K');
}
else
{
UARTCharPut(UART1_BASE, 'K');
}
for(i=0; i<100000;i> {
}
}
}
I think what is happening is that the in circuit debugger sets up the UART0 since that is used often in sample code. None of the example code shows this solution.
Any way, I hope I have saved someone some time.
TF
P.S. The signals out of the chip are inverted from standard RS232. It is expected that your circuit will use drivers that convert the 0 to 3 volt TTL output to inverted -5 to + 5 volt RS232.
Thus if you directly wire a DB9 connector to a chip port and then into a PC serial port, it will not work.