Part Number: EK-TM4C123GXL
I'm trying to get my TM4C communicating over Bluetooth with a BLUESMiRF Silver device. I would like to send simple two-letter commands from my laptop to the BLUESMiRF via Bluetooth, and then via UART from the BLUESMiRF to the TM4C.
Laptop ---(Bluetooth)---> BLUESMiRF ---(UART)---> TM4C
My connections are as follows:
TM4C UART PB0 RX <----> BLUESMiRF TX
TM4C UART PB1 TX <---> BLUESMiRF RX
TM4C +3.3V <---> BLUESMiRF Vcc
TM4C GND <---> BLUESMiRF GND
I am powering the TM4C via micro-USB connected to my PC.
I am trying to type the commands into Tera Term that is connected to a COM port that is the Bluetooth connection to the BLUESMiRF. When I connect to the correct COM it verifies my Bluetooth connection by lighting a green LED on the BLUESMiRF.
If somebody could check my code and see if something is wrong, I would be very appreciative. When I type in Tera Term I'm expecting it to send the data to the TM4C and trigger a UART RX interrupt, and then print certain information depending on the data sent. Thanks.
-----------------------------------------------------------------------------
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_ints.h"
#include "driverlib/interrupt.h"
#include "driverlib/debug.h"
#include "driverlib/fpu.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "utils/uartstdio.h"
#include <string.h>
#ifdef DEBUG
void
__error__(char *pcFilename, uint32_t ui32Line)
{
}
#endif
char command[2] = " ";
char speed[4] = " ";
void UART1Handler(void)
{
uint32_t ui32Status;
ui32Status = ROM_UARTIntStatus(UART1_BASE, true);
ROM_UARTIntClear(UART1_BASE, ui32Status);
UARTgets(command, strlen(command) + 1);
UARTprintf("\n");
if (!strcmp(command, "SS")) // Set Speed
{
UARTprintf("Please enter desired motor speed from 1-100 percent.\n");
UARTgets(speed, strlen(speed) + 1);
}
else if (!strcmp(command, "ES")) // Emergency Stop
{
UARTprintf("Stopping motors...");
}
else if (!strcmp(command, "ST")) // Start
{
UARTprintf("Starting motors...");
}
UARTprintf("\n");
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0);
SysCtlDelay(10000000);
}
void ConfigureUART(void)
{
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
ROM_IntMasterEnable();
ROM_GPIOPinConfigure(GPIO_PB0_U1RX);
ROM_GPIOPinConfigure(GPIO_PB1_U1TX);
ROM_GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);
UARTClockSourceSet(UART1_BASE, UART_CLOCK_PIOSC);
UARTStdioConfig(1, 115200, 16000000);
IntRegister(INT_UART1, UART1Handler);
ROM_IntEnable(INT_UART1);
ROM_UARTIntEnable(UART1_BASE, UART_INT_RX | UART_INT_TX);
}
/******************************************* MAIN ***********************************************/
int main(void)
{
ROM_FPULazyStackingEnable();
ROM_SysCtlClockSet(
SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2);
ConfigureUART();
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2);
while (1)
{
}
}