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.

Problem in Connecting HC05 with Stellaris launchpad

Other Parts Discussed in Thread: MAX232

Hello,


I am using HC-05 Bluetooth module connected using UART3 with Stellaris launchpad. I want to perform an half duplex communication. ie only transmitting from Bluetooth device. I ll see the transmitted data in an bluetooth terminal App installed in android phone.  I wrote a program for UART Transmitter.


Whenever i connect my Bluetooth device to launchpad, there was a problem arises. After debugging, the data is transmitted from board but i am unable to receive the transmitted data in Bluetooth App. It seems that there won't be any issue in the program. I thought that there might have prob in Bluetooth module but i have tested with MSP430 launchpad and it was working fine. Even i have connected a voltage divider of 2k and 1k between my TX pin of MCU and Gnd.

Herewith i have enclosed my program. Kindly verify and help me in this regard since i was struggling for a week..

#include "inc/lm4f120h5qr.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "driverlib/gpio.h"
#include "utils/uartstdio.h"
#include "driverlib/pin_map.h"


unsigned int in,q;
unsigned int i,t=0;


void bluetooth_init();
void bluetooth_transmit();

void main(){      
SYSCTL_RCGC2_R = SYSCTL_RCGC2_GPIOB|SYSCTL_RCGC2_GPIOE|SYSCTL_RCGC2_GPIOC; //Enable clock for PORTF  


while(1){

bluetooth_init();
delay(200);
bluetooth_transmit();
delay(2000);

}}

void delay(unsigned int value){
int i,j;
for(i=0;i<value;i++){
for(j=0;j<100;j++);
}}


void bluetooth_init(){
SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |SYSCTL_XTAL_16MHZ);   
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);
UARTConfigSetExpClk(UART3_BASE, SysCtlClockGet(),9600,(UART_CONFIG_WLEN_8 |UART_CONFIG_STOP_ONE |UART_CONFIG_PAR_NONE));
UARTEnable(UART3_BASE);
}

void bluetooth_transmit(){
unsigned int i;
for(i=0;i<11;i++){
UARTCharPut(UART3_BASE,'a');
}
}

Thanks,

Revathi.T

  • Hello Revathi,

    Some clarifications are needed....

    Revathi T said:
    Whenever i connect my Bluetooth device to launchpad, there was a problem arises. After debugging, the data is transmitted from board but i am unable to receive the transmitted data in Bluetooth App. It seems that there won't be any issue in the program. I thought that there might have prob in Bluetooth module but i have tested with MSP430 launchpad and it was working fine. Even i have connected a voltage divider of 2k and 1k between my TX pin of MCU and Gnd.

    "After debugging, the data is transmitted from board but i am unable to receive the transmitted data in Bluetooth App."

    From which board did you confirm the data is transmitted? launchpad to the HC05? From HC05 to BT?

    "It seems that there won't be any issue in the program."

    Then why did you post the code to be reviewed for an error if you've confirmed there is no error in the code? 

    What input voltage are you needing for the HC05 device? The Stellaris part will have an output of approximately 3.3V.

    With the above information unknown, I would receommend checking the following:

    1.) Check the pinouts of the boosterpack connectors between the HC05 and the Stellaris Launchpad. Insure the UART3 pins are located in the same location as used on the MSP430 Launchpad. Also make sure the correct power and ground connections are in place.

    2.) check the baud rates for the UART communications required by the HC05 to insure they are aligned.

    3.) If the HC05 requires a different IO voltage other than 3.3V on Tx, it would most likely need a different supply voltage so check this as well.

  • Hello Chuck,

    Let me clarify the queries u have asked.

    I. I have verified the UART transmitter program by connecting an USB to serial converter to other PC. I am receiving the character what ever i m transmitting.

    II. I have connected external DC supply 5V to HC-05 Bluetooth module since it accepts from 3.6 to 5V. Even we can connect 5V from stellaris launchpad also.

    III. Regarding Baud rate of Bluetooth module, i have used 9600 and verified its working with serial terminal.

    By checking all these parameters, Even though i am unable to get the data in my Bluetooth terminal App.

    I have connected HC-05 Tx to UART3 - PC7 (Tx) and Rx to PC6 (Rx) with a common ground. Apart from this, Is any other connections to be made?

  • Hello Revathi,

    Check the output levels of the Stellaris UART. I believe you will find them to be <3.6V which would be less than the allowable range for your HC05 device. You will, most likely, need to add a level shifter into the circuit or a UART transceiver of some type.
  • Hi,

    Seems you don't have any single code line to deal with receiving, only with transmitting. If you did not forget to post it, then that should be the cause of your problem.

    Usually/most frequent this is managed with interrupts, but in some cases also polling could be a solution.

    One more thing: your bluetooth_init() calls SysCtlClockSet - this is time consuming routine and should be done only once, not inside while(1) loop. If you will use uart interrupt for receiving this repeated call may cause problems.

  • Hi Chuck,

    I tried with Max232 level converter also.. I  m getting 3.3V as output from my transmitter pin of stellaris launchpad. But still the same issue.

  • Revathi,

    So, the quickest path to a solution is to compare the working implementation with the non-working implementation. i.e., you stated that you had this working with the MSP430 launchpad. Correct?

    If this is the case and you have verified that the output of the Stellaris UART is working, you should check the connections of the Stellaris board to the HC05 to insure proper continuity and that voltage levels at the HC05 pin are at the right levels (this should include any UART signals, supply pins, enable/disable pins, etc.). Also, insure that the data being sent is the same as the data being sent when using the MSP430 and with the same sequence, format, timing... be very detailed/meticulous with your comparison to find the differences.

    Also, I don't believe it is the source of your issue, but it would be best to move bluetooth_init() outside of the while(1) as Petrei has suggested. The current call location would have the potential to cause glitching on the signal lines and may cause some issues. In effect, the calls within the bluetooth_init() function have nothing to do with the bluetooth module and more to do with the Stellaris startup configuration and really should only be called one time at the start of main.