2015-09-28 10:00 AM
Hello! First of all let me start by telling you that i'm a trully beginner.
So, im trying to receive a string like ''hello world'' in the termite .I already can see the bluetooth hc-05 though my phone. I can connect the bluetooth on the termite however i cant receave anything from it.My code is the following:/* Includes ------------------------------------------------------------------*/#include ''stm32f4_discovery.h''#include ''stm32f4xx_gpio.h''#include ''stm32f4xx_rcc.h''#include ''stm32f4xx.h''#include ''stm32f4xx_usart.h''#include <string.h>#include <stdio.h>GPIO_InitTypeDef GPIO_InitStructure;USART_InitTypeDef USART_InitStructure;void delay(unsigned long tempo) { volatile unsigned long i; i = tempo; do i-- ; while (i !=0); }void USART_put(USART_TypeDef* USARTx, volatile char *s){ while(*s){ // wait until data register is empty while( !(USARTx->SR & 0x00000040) ); USART_SendData(USARTx, *s); while(USART_GetFlagStatus(USART3, USART_FLAG_TC) == RESET) { } *s++; }}void GPIO_USART_Configuration(void){ RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE); RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE); /* Configure USART Tx as alternate function */ GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_Init(GPIOC, &GPIO_InitStructure); /* Connect PXx to USARTx_Tx*/ GPIO_PinAFConfig(GPIOC, GPIO_PinSource10, GPIO_AF_USART3); } void USART3_Configuration(void) { USART_InitStructure.USART_BaudRate = 38400; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_No; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Tx; USART_Init(USART3, &USART_InitStructure); USART_Cmd(USART3, ENABLE); // enable USART2 }void usart_inisialisasi() { GPIO_USART_Configuration(); USART3_Configuration(); }int main(void) {SystemInit();usart_inisialisasi();}(obviously i tried to use usart_put but i cant use it correctly i think)any help would be appreciated.Thank you,2015-09-28 10:32 AM
So you're got something like
while(1) USART_put(USART3, ''Hello World!\r\n''); Right? Have you configured the HC-05 to be at 38400 baud, at it's end not the phone's end? Or is this it's default?2015-09-28 10:42 AM
yes my code was something like that but i cant put it working. the baud-rate is correct . maybe something with the connections on the stm32 to the bluetooth? i only connected the bluetooth rx - stm usart3 tx ; bluetooth tx - stm usart3 rx ; vcc and ground.
thanks for trying to help and replying me . really really aprecciated!