cancel
Showing results for 
Search instead for 
Did you mean: 

Bluetooth HC-05 and STM32F4 Discovery

samotan
Associate II
Posted on November 20, 2014 at 00:50

Hello i want to test my BT on Discovery board. I connected all pins correctly and build easy code for recive data and turn on the light.In my code i use this function to recive data on STM.

if
(USART_GetFlagStatus(USART3, USART_FLAG_RXNE)!=RESET)
i=USART_ReceiveData(USART3);

I send numbers 1,2,3,6,8 (i is integer) from RealTerm terminal from my laptop to STM. In Debugger i see under ''i'' place random numbers like 252, 244, 252, 255 . What is wrong with my code ? or problem happens in other side ?
4 REPLIES 4
Posted on November 20, 2014 at 01:16

Stick a scope on it an confirm the baud rates by observing the data patterns and bit timings, both from the bluetooth side, and by transmitting from the STM32 side.

It's important that the code is compiled with the code configured for using the 8 MHz on the STM32F4-DISCO, and that HSE_VALUE within the project also reflects this.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
samotan
Associate II
Posted on November 20, 2014 at 01:51

i have STM32F4 Discovery and using CooCox :) HSE_Value is 8Mhz like my external oscilator on board but i cant switch them to use HSE, only can change to HSI 16Mhz or 168Mhz (i watch variable SystemCoreClock();

in datasheet HC-05 are 9600 , 8n1 so i use it in usart configuration in STM. it is possible my HC got diferrent setup than datasheet ?

Posted on November 20, 2014 at 18:02

it is possible my HC got different setup than datasheet ?

I didn't configure or sell you the parts, I have no idea how they might be configured for the parts you have. I'd start with the scope, or by attaching to a PC, and confirm what is and isn't functioning, and at what speeds.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
samotan
Associate II
Posted on November 20, 2014 at 22:45

ouuhhh now is everything working ok ...

i have to change HSE Value to 8000000 and PLL_N to 8