Microcontroller › 8051 › 8051 Interfacing with bluetooth
- This topic has 5 replies, 2 voices, and was last updated 9 years, 7 months ago by Ashutosh Bhatt.
-
AuthorPosts
-
April 2, 2015 at 8:47 am #3598ShivParticipant
I am trying to do "ultrasonic range finder" project mentioned here. Instead of using 7 segment displays, i am tryiing to interface bluetooth to serial port of 8051 and i am transfering that data to laptop to process it there. But despite of doing connections in a correct manner there has been no tranmisison of data from 8051 to laptop. I am using real term software on laptop. I have used 9600 baud rate. The bluetooth module i am using is hc-05.
PS- 1)I have checked code in keil by running it step by step mode in debuggin and program does what is expected .
2) I have connected HC-05 in correct manner( tx of bt to rx of 8051,rx of bt to tx of 8051)
3) hc-05 and software real term are working fine since i have checked them using arduino.
please help i am posting my source code here:
ORG 00HSETB P3.0//sets p3.0 as input from bluetooth moduleCLR P3.1//sets p3.1 as output to bluetooth moduleCLR P3.2 // sets P3.2 as output for sending triggerSETB P3.3 // sets P3.3 as input for receiving echoMAIN: MOV TMOD,#00100000B // sets timer1 as mode 2 auto reload timerMOV TL1,#210D // loads the initial value to start counting fromMOV TH1,#210D // loads the reload valueMOV A,#00000000B // clears accumulatorSETB P3.2 // starts the trigger pulseACALL DELAY1 // gives 10uS width for the trigger pulseCLR P3.2 // ends the trigger pulseHERE: JNB P3.3,HERE // loops here until echo is receivedBACK: SETB TR1 // starts the timer1HERE1:JNB TF1,HERE1 // loops here until timer overflows (ie;48 count)CLR TR1 // stops the timerCLR TF1 // clears timer flag 1INC A // increments A for every timer1 overflowJB P3.3,BACK // jumps to BACK if echo is still availableMOV R4,A // saves the value of A to R4ACALL SENDACALL DELAYACALL DELAYACALL DELAYSJMP MAIN // jumps to MAIN loopDELAY1: MOV R6,#2D // 10uS delayLOOP1: DJNZ R6,LOOP1RETSEND: MOV TMOD,#20H// timer 1 in mode 2 autoreloadMOV TH1,#0FDH//baud rate 9600 generationMOV SCON,#50HSETB TR1MOV A,R4MOV SBUF,A//serial tranmisison via tx connected to bluetooth moduleTHERE: JNB TI,THERECLR TIRETDELAY: MOV TMOD,#00010000BMOV TH1,#00HMOV TL1,#00HSETB TR1HERE3: JNB TF1,HERE3CLR TR1CLR TF1RETENDApril 3, 2015 at 7:15 pm #12750Ashutosh BhattParticipantdoes your bluetooth device pairs with laptop's inbuilt bluetooth? u can also try flash magic software. it has also serial port monitor
April 4, 2015 at 5:45 pm #12762ShivParticipantyes it pairs with laptop properly, and even sends data correctly i have checked its pairing using arduino and it works correctly. I dont know what wrong happens when i do it with AT89S52(8052)
April 6, 2015 at 11:58 am #12769Ashutosh BhattParticipanti think there is a problem in baud rate setting.
which crystal u r using? you must use 11.0592 MHz crystal only
April 6, 2015 at 12:49 pm #12771ShivParticipantYes that only i am using . Crystal of 11.0592 MHZ along with two 33pf capacitors connected between 18 and 19 pins to ground . Still the problem persists
April 17, 2015 at 11:15 am #12802Ashutosh BhattParticipantthe micro controller sends HEX data
while any serial terminal software only displays ASCII characters
so convert ur HEX data into ASCII and then send them one by one to computer/laptop through bluetooth
-
AuthorPosts
- You must be logged in to reply to this topic.