rdhk414
Newbie level 1
- Joined
- Jul 7, 2014
- Messages
- 1
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 7
Hello,
Can anyone worked on ST microcontroller, Actually I am working on project, in which i have to interface STM8l microcontroller to BM-S02 bluetooth module.
Can any one have any sample code because I am new. I read data sheet and write following code but its not working.
----------------------
Can anyone please help or share the trans rec code for bluetooth module..
Thanks in advance.
Can anyone worked on ST microcontroller, Actually I am working on project, in which i have to interface STM8l microcontroller to BM-S02 bluetooth module.
Can any one have any sample code because I am new. I read data sheet and write following code but its not working.
----------------------
Code:
void main()
{
//////////// Bluetooth port initialize/////////////
GPIO_Init(BLE_Port_1,BCT_PIN,GPIO_Mode_In_FL_No_IT);// set as a input
GPIO_Init(BLE_Port_1,BRT_PIN, GPIO_Mode_Out_PP_High_Fast); // set as a OUTPUT
GPIO_Init(BLE_Port_2,EN_PIN , GPIO_Mode_Out_PP_High_Fast);// set as a OUTPUT
CLK_PeripheralClockConfig(CLK_Peripheral_USART1, ENABLE); //enable usart peripheral
USART_Init(USART1, 9600, USART_WordLength_8b, USART_StopBits_1, USART_Parity_No, USART_Mode_Rx);
USART_Cmd(USART1,ENABLE);
//////////////////////////////////////////////////
GPIO_ResetBits(BLE_Port_2,EN_PIN); // Enable bluetooth
CLK_PeripheralClockConfig(CLK_Peripheral_USART1, ENABLE); //enable usart peripheral
USART_Init(USART1, 9600, USART_WordLength_8b, USART_StopBits_1, USART_Parity_No, USART_Mode_Rx);
USART_Cmd(USART1,ENABLE);
GPIO_ResetBits(BLE_Port_2,EN_PIN); // Enable bluetooth
while (1)
{
for(int i=0;i<12;i++)
{
BLE_Ack[i]=USART_ReceiveData8(USART1); //confirmation from module
}
if ( BLE_Ack[0]== 'T' && BLE_Ack[1]== 'T')
{
while(1)
{
GPIO_ResetBits(BLE_Port_1, BRT_PIN);
for(int i=0;i<12;i++)
{
USART_SendData8(USART1, Module_Name[i]); ///Set module name.
}
Delay(20);
GPIO_SetBits(BLE_Port_1, BRT_PIN);
Delay(20);
for(int i=0;i<12;i++)
{
BLE_Ack[i]=USART_ReceiveData8(USART1); //confirmation from module
}
if ( BLE_Ack[3]== 'O' && BLE_Ack[4]== 'k')
{
GPIO_SetBits(LED2_PORT,LED2_PIN); // LED high
}}}
else
break; }}
Can anyone please help or share the trans rec code for bluetooth module..
Thanks in advance.
Last edited by a moderator: