This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/TM4C123GH6PM: HC 05 with tiva tm4c123gh6pm

Part Number: TM4C123GH6PM


Tool/software: Code Composer Studio

Cannot send nor recieve data from bluetooth module hc 05 with the following code written in ccs-

#include <stdint.h>
#include <stdio.h>
#include <stdbool.h>
#include "inc/tm4c123gh6pm.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_ints.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "driverlib/timer.h"
#include "driverlib/interrupt.h"
#include <math.h>
#include <string.h>
#include"driverlib/pin_map.h"
#include"driverlib/sysctl.h"
#include"driverlib/uart.h"
#include"driverlib/uart.c"
#include "driverlib/adc.h"

//int32_t d='x';
unsigned char d;
int main(void)
{
    int u=0;
    /*Set the Bluetooth UART*/
    SysCtlClockSet(SYSCTL_SYSDIV_10|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
   
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
    GPIOPinConfigure(GPIO_PB0_U1RX);
    GPIOPinConfigure(GPIO_PB1_U1TX);
   


    /* Pull up the PB0 and PB1 */
    GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_0 ,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU);

    /* Make the UART pins be peripheral controlled. */
    GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);

 

    /* Sets the configuration of a UART. */
    UARTConfigSetExpClk(UART1_BASE,16000000, 9600, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));



    //  while(UARTCharsAvail(UART1_BASE));
    //
    //  unsigned char d = UARTCharGet(UART1_BASE);



    //UARTCharPut(UART1_BASE,'b');


while(1)
{
    d = UARTCharGet(UART1_BASE);
    UARTCharPut(UART1_BASE,76);
        UARTCharPut(UART1_BASE,'b');
        UARTCharPut(UART1_BASE,'c');}

    return 0;
}

  • Hi,
    I have some comments.

    - You don't need the below line. When you call GPIOPinTypeUART() it will configure the pin buffer accordingly for you.
    GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_0 ,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU);

    - You configure the System Clock with the below options. You are using the PLL as your clock source and configuring the System Clock to 20MHz. However, you also configure the UART clock for 9600 baud rate with an input UART clock (or system clock) of 16MHz. You should either change your System clock to use the OSC rather than PLL or configure the UART clock in your UARTConfigSetExpClk to 20Mhz, one way or the other.
    SysCtlClockSet(SYSCTL_SYSDIV_10|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
    UARTConfigSetExpClk(UART1_BASE,16000000, 9600, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));

    - use a scope to see if you are getting proper signals on the UARTTX and UARTRX pins.