Tool/software: Code Composer Studio
Hey folks,
I need help to figure out how to get the Bluetooth module HC06 work with my tiva. No error with the compiler. However, It didn't give the output I seek. PF1 voltage is zero. Please help me with that.
My code:
#include <stdint.h>
#include <stdbool.h>
//#include <driverlib.h>
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "driverlib/debug.h"
#include "driverlib/fpu.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#define LEDPort GPIO_PORTF_BASE
//Funtion Prototypes
void RedLedHigh();
void RedLedLow();
//*****************************************************************************
//
// The error routine that is called if the driver library encounters an error.
//
//*****************************************************************************
#ifdef DEBUG
void
__error__(char *pcFilename, uint32_t ui32Line)
{
}
#endif
//*****************************************************************************
//
// The UART interrupt handler.
//
//*****************************************************************************
void UARTIntHandler(void)
{
uint32_t ui32Status;
//
// Get the interrrupt status.
//
ui32Status = ROM_UARTIntStatus(UART3_BASE, true);
//
// Clear the asserted interrupts.
//
ROM_UARTIntClear(UART3_BASE, ui32Status);
//
// Loop while there are characters in the receive FIFO.
//
while(ROM_UARTCharsAvail(UART3_BASE))
{
char c=ROM_UARTCharGetNonBlocking(UART3_BASE);
switch(c)
{
case 'a':
RedLedHigh();
break;
case 'b':
RedLedLow();
break;
}
}
}
void RedLedHigh(void)
{
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1, 0xFF);
}
void RedLedLow(void)
{
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1, 0);
}
//*****************************************************************************
//
// Send a string to the UART.
//
//*****************************************************************************
void
UARTSend(const uint8_t *pui8Buffer, uint32_t ui32Count)
{
//
// Loop while there are more characters to send.
//
while(ui32Count--)
{
//
// Write the next character to the UART.
//
ROM_UARTCharPutNonBlocking(UART3_BASE, *pui8Buffer++);
}
}
//*****************************************************************************
//
// This example demonstrates how to send a string of data to the UART.
//
//*****************************************************************************
int main(void)
{
// Set the clocking to run directly from the crystal.
//
ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
//
// Enable the GPIO port that is used for the on-board LED.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
//
// Enable the GPIO pins for the LED (PF2).
//
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
// Enable the peripherals used by this example.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART3);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
//
// Enable processor interrupts.
//
ROM_IntMasterEnable();
//
// Enable the UART interrupt.
//
ROM_IntEnable(INT_UART3);
ROM_UARTIntEnable(UART3_BASE, UART_INT_RX | UART_INT_RT);
GPIOPinConfigure(GPIO_PC6_U3RX);
GPIOPinConfigure(GPIO_PC7_U3TX);
ROM_GPIOPinTypeUART(GPIO_PORTC_BASE, GPIO_PIN_6 | GPIO_PIN_7);
//
// Configure the UART for 115,200, 8-N-1 operation.
//
ROM_UARTConfigSetExpClk(UART3_BASE, ROM_SysCtlClockGet(), 9600,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));
//
// Enable the UART interrupt.
//
ROM_IntEnable(INT_UART3);
ROM_UARTIntEnable(UART3_BASE, UART_INT_RX | UART_INT_RT);
while(1)
{
}
}