Tool/software: Code Composer Studio
Hey guys,
So I've been learning the TM4C123 for a bit and I've hit a snag when connecting to a different UART pin. Because I'm trying to run SensHub and the HC-06 on the same controller I'm restricted by what pins I can connect to, so I tried to move an example of UART1 to UART3, and while following the workbook and datasheet I can't see where my error is.
When running with UART 1 this is the code and the output:
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "uart.h"
#include "uartstdio.h"
int main(void) {
SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
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);
UARTClockSourceSet(UART1_BASE, UART_CLOCK_PIOSC); //16 MHz crystal oscill
UARTStdioConfig(1, 38400, 16000000); //port 1, baud rate, 16 MHz oscill
IntMasterEnable(); //enable processor interrupts
IntEnable(INT_UART1); //enable the UART interrupt
UARTIntEnable(UART1_BASE, UART_INT_RX | UART_INT_RT); //only enable RX and TX interrupts
UARTCharPut(UART1_BASE, 'E');
UARTCharPut(UART1_BASE, 'n');
UARTCharPut(UART1_BASE, 't');
UARTCharPut(UART1_BASE, 'e');
UARTCharPut(UART1_BASE, 'r');
UARTCharPut(UART1_BASE, ' ');
UARTCharPut(UART1_BASE, 'T');
UARTCharPut(UART1_BASE, 'e');
UARTCharPut(UART1_BASE, 'x');
UARTCharPut(UART1_BASE, 't');
UARTCharPut(UART1_BASE, ':');
UARTCharPut(UART1_BASE, ' ');
while (1) //let interrupt handler do the UART echo function
{
// if (UARTCharsAvail(UART0_BASE)) UARTCharPut(UART0_BASE, UARTCharGet(UART0_BASE));
}
}
void UARTIntHandler(void)
{
uint32_t ui32Status;
ui32Status = UARTIntStatus(UART1_BASE, true); //get interrupt status
UARTIntClear(UART1_BASE, ui32Status); //clear the asserted interrupts
while(UARTCharsAvail(UART1_BASE)) //loop while there are chars
{
UARTCharPutNonBlocking(UART1_BASE, UARTCharGetNonBlocking(UART1_BASE)); //echo character
}
}
However, when trying to switch to UART 3 I don't get any output. This is the code:
Actually, It seems this version get's stuck on the first character.
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "uart.h"
#include "uartstdio.h"
int main(void) {
SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
SysCtlPeripheralReset(SYSCTL_PERIPH_UART3);
SysCtlPeripheralReset(SYSCTL_PERIPH_GPIOC);
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART3);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
GPIOPinConfigure(GPIO_PC6_U3RX);
GPIOPinConfigure(GPIO_PC7_U3TX);
GPIOPinTypeUART(GPIO_PORTC_BASE, GPIO_PIN_6 | GPIO_PIN_7);
UARTClockSourceSet(UART3_BASE, UART_CLOCK_PIOSC); //16 MHz crystal oscill
UARTStdioConfig(3, 38400, 16000000); //port 1, baud rate, 16 MHz oscill
IntMasterEnable(); //enable processor interrupts
IntEnable(INT_UART3); //enable the UART interrupt
UARTIntEnable(UART3_BASE, UART_INT_RX | UART_INT_RT); //only enable RX and TX interrupts
UARTCharPut(UART3_BASE, 'E');
UARTCharPut(UART3_BASE, 'n');
UARTCharPut(UART3_BASE, 't');
UARTCharPut(UART3_BASE, 'e');
UARTCharPut(UART3_BASE, 'r');
UARTCharPut(UART3_BASE, ' ');
UARTCharPut(UART3_BASE, 'T');
UARTCharPut(UART3_BASE, 'e');
UARTCharPut(UART3_BASE, 'x');
UARTCharPut(UART3_BASE, 't');
UARTCharPut(UART3_BASE, ':');
UARTCharPut(UART3_BASE, ' ');
while (1) //let interrupt handler do the UART echo function
{
}
}
void UARTIntHandler(void)
{
uint32_t ui32Status;
ui32Status = UARTIntStatus(UART3_BASE, true); //get interrupt status
UARTIntClear(UART3_BASE, ui32Status); //clear the asserted interrupts
while(UARTCharsAvail(UART3_BASE)) //loop while there are chars
{
UARTCharPutNonBlocking(UART3_BASE, UARTCharGetNonBlocking(UART3_BASE)); //echo character
}
}
Thank you for any help or suggestions.

