loading

BLUETOOTH INTERFACING WITH 8051(AT89C/S51/52) PLZ HELP

Hello guruz,
recently i bought n bluetooth UART module (http://robokits.co.in/shop/index.php?main_page=product_info&products_id=354) RKI 1545
I tried interfacing it with 8051 using the 10,11 pin UART pins, using SCON register(mode1) baud rate 9600. But there is no reception or transmission.
However the bt module is working fine. Passed the loop feedback test(joined theRx to Tx pin of module standalone....link established echo received on Putty on WIN7 and blueterm android app )
 
CODE:
#include<reg51.h>

void ini()     // Initialize Timer 1 for serial communication
{
TMOD=0x20;  //Timer1, mode 2, baud rate 9600 bps
TH1=0XFD;
SCON=0x51;
TR1=1;
}

void recieve()  //Function to receive serial data
{
unsigned char value;
while(RI==0);
value=SBUF;
P1=value;
RI=0;
}

void transmit()  // Funtion to transmit serial data
{
P2=0xF4;
SBUF=P2;
while(TI==0);
TI=0;
SBUF=P1;
while(TI==0);
TI=0;
}

void main()
{
while(1)
{
  ini();
  recieve();
  transmit();
}
}

sort by: active | newest | oldest
FAisalF175 months ago

how to operate bulb using bluetooth module , 8051 microcontroller and android bluetooth app ?

This could be a guide:

https://www.pantechsolutions.net/project-kits/interfacing-bluetooth-with-8051-primer

pls help me how to write c coding for interfacing bluetooth hc 05 with 8051 microcontroller (at89s52) i have to controll relay circuit using bluetooth

Help me

Written much on the 8052 before ? In your main loop, you're reinitialising the UART every time through the loop. Connect the 8052 to your PC serial port, and see if you can get it to echo. You'll need a MAX232 or 202 chip though.
Here' s my usual serial port initialisation.
You may need to change the timer load values depending on your crystal speed.

MOV A,TMOD
ANL A,#0FH    
ADD A,#20H
MOV TMOD,A
CLR SM0
SETB SM1
MOV TH1,#246
SETB TR1
MOV A,PCON
ORL A,#80H
MOV PCON,A
SETB REN
SETB TI
skumar112 (author)  steveastrouk4 years ago
already did that using max232 n serial cable ..win xp hyper terminal....the progrm works just fine.......can u plz provide serial mode initialization in C... thnks in advance
WHICH program works ? The 8052 ?

No, you can work it out from that, or you can just use in-line assembler.