Hello TI community,
I am just beginning with a Tiva C series Launchpad and I am using CCS v6.1 to develop some code. Eventually I'd like to use the UART to drive a RF module (non-TI), and so I have written some simple code to write values to UART1, and then I try and read them out to the PuTTY console on UART0. Try as I might to self-educate, it seems that I've missed something with how to program this device. I've worked trhough a good number of the LaunchPad workshop labs and searched through this forum, and my suspicion is that I have a locked pin on UART1. Here is my code, and the device in particular on my launchpad is the TM4C123GH6PM. Any help you can give or tips for beginners would be appreciated, and sorry for the assuredly high-caliber noob-ness of this code.
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/uart.h"
void UART_Init(void);
void UART_Init(void){
SysCtlPeripheralReset(SYSCTL_PERIPH_UART1);
SysCtlPeripheralReset(SYSCTL_PERIPH_GPIOB);
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
GPIOPinConfigure(GPIO_PB0_U1RX);
GPIOPinConfigure(GPIO_PB1_U1TX);
GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);
UARTConfigSetExpClk(UART1_BASE, SysCtlClockGet(), 115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
GPIOPinConfigure(GPIO_PA0_U0RX);
GPIOPinConfigure(GPIO_PA1_U0TX);
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));
SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
}
int main(void)
{
UART_Init();
while(1)
{
UARTCharPut(UART1_BASE, 'a');
if (UARTCharsAvail(UART1_BASE)) {UARTCharPut( UART0_BASE, UARTCharGet( GPIO_PORTB_BASE));}
// Delay for a bit
SysCtlDelay(20000000);
UARTCharPut(UART1_BASE, 'b');
if (UARTCharsAvail(UART1_BASE)) {UARTCharPut( UART0_BASE, UARTCharGet( GPIO_PORTB_BASE));}
// Delay for a bit
SysCtlDelay(20000000);
UARTCharPut(UART0_BASE, 'c');
if (UARTCharsAvail(UART1_BASE)) {UARTCharPut( UART0_BASE, UARTCharGet( GPIO_PORTB_BASE));}
// Delay for a bit
SysCtlDelay(20000000);
}
}