Help with bluetooth...


Closed Thread
Results 1 to 25 of 25

Hybrid View

  1. #1
    Join Date
    Oct 2008
    Posts
    65

    Unhappy Help with bluetooth...

    Hi everyone, I got an EGBC-04 bluetooth module. When I powered the EGBC-04 my pc detects it(Bluetooth discovery). But I'm having problem communicating with it(sending data only). I place leds to test the communication setup from PC to EGBC04 to PIC16F877A but no luck. Kindly check my setup and codes in the pic....I appreciate any help.

    Code:
    CLEAR		;read and write hardware USART
    B1	VAR     BYTE	;initialize USART
    
        TRISB = %00000000
        PortB = %00000000
    	TRISC = %10111111	;set TX (PORTC.6) to out, rest in
    	SPBRG = 25	;set baud rate to 2400
    	RCSTA = %10010000	;enable serial port and continuous receive
    				
    LOOP:		
    GOSUB CHARIN	;get a character from serial input, if any
    	IF B1 = 0 THEN LOOP 	;no character yet
    	GOTO LOOP	;do it forever
    			;subroutine to get a character 
    			;from usart receiver
    CHARIN: 
    B1 = 0			;preset to no character received
    	IF PIR1.5 = 1 THEN	;if receive flag then...
    		B1 = RCREG	;get received character to b1
    
    	   IF B1 = 65 then  
    	       If PortB.0 = 0 then
    	          High PortB.0 
               else
                  Low PortB.0
               Endif 	           
    	   ENdif
           
       ENdif            
    goto loop
    Thanks in advance,
    mbox
    Attached Images Attached Images  

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    I have not used an EGBC-04, but looking at the data sheet I will ask...

    Did you set the EGBC-04 for the baud rate you are using? I think it defaults to 9600.
    Did you set it as SLAVE? I think that is what you want.

    And, I would also think an inverter chip (RS232) is needed.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Oct 2008
    Posts
    65

    Default

    Hi Dave, I did adjust it to 9600 and do I really need the inverter chip? As I understand I only need it if I directly connect the BT module to the PC. But instead I have a USB bluetooth attached to PC to link with th EGBC-04. Please help..

    thanks,
    mbox
    Last edited by mbox; - 4th October 2009 at 13:47.

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    Quote Originally Posted by mbox View Post
    Hi Dave, I did adjust it to 9600 and do I really need the inverter chip? As I understand I only need it if I directly connect the BT module to the PC. But instead I have a USB bluetooth attached to PC to link with th EGBC-04. Please help..

    thanks,
    mbox
    I do not know for sure but to have a PIC communicate with a PC and using hardware serial the inverter chip is needed.

    I would think that any data passing through the BT module is inverted. As a quick test you could try SERIN2/SEROUT2 and use inverted mode.

    And you have your serial on the PIC set as 2400 baud. The BT is 9600???
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Oct 2008
    Posts
    65

    Default

    Hi Dave, thanks for the replies and I really do appreciate it. Ahm...I'm a little confuse, I hope you dont mind if I'm very slow to pick it all up. But may I explaine my hardware setup to understand what I'm missing.

    PC side: [Port - COM7] [Baud rate - 9600] [Byte size - 8] [Stop bit - 1]
    Sends character data 'A' over COM7 as given(device discovery).

    EBC-04 side: [Operates on 3.3v] [Baud rate - 9600] [Byte size - 8] [Stop bit - 1]

    PIC side: [Baud rate - 2400] PortC.7-->Rx

    Okay, I understand that I need to change 2400 to 9600 from PIC baud rate to communicate with EGBC. There are two option as I see, either I change the baud rate of the EGBC using AT commands by connecting to the pc with LVTTL TO RS-232 CONVERTER or change PIC's baudrate. But I dont have TTL to RS232 converter right now. So changing the Pic's baud rate is my option. I'm using 4MHZ crystal..how do I change it to 9600?

    Thanks,
    mbox
    Attached Images Attached Images  
    Last edited by mbox; - 5th October 2009 at 02:23.

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    The easy way to figure the USART settings is to use Mister E's PicMultiCalc
    http://www.picbasic.co.uk/forum/showthread.php?t=4994

    It gives
    Code:
     
    RCSTA = $90 ' Enable serial port & continuous receive
    TXSTA = $24 ' Enable transmit, BRGH = 1
    SPBRG = 25  ' 9600 Baud @ 4MHz, 0.16%
    But even changing the baud I still think you will need an inverter.
    Dave
    Always wear safety glasses while programming.

Similar Threads

  1. Bluetooth problme with the 16F877A
    By slimpeng in forum Bluetooth
    Replies: 6
    Last Post: - 27th June 2009, 12:06
  2. interaction between Bluetooth and PIC MCU
    By veenadari in forum Bluetooth
    Replies: 1
    Last Post: - 23rd June 2009, 15:03
  3. help my bluetooth and PIC 16F877A?
    By slimpeng in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 18th March 2008, 06:52
  4. Bluetooth GPS and PBP interfacing
    By RFsolution in forum Bluetooth
    Replies: 0
    Last Post: - 5th January 2006, 11:17
  5. Bluetooth wireless with PIC / HSERIN / DAC
    By rpatel in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 20th December 2004, 22:13

Members who have read this thread : 2

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts