2

Author Topic: Bluetooth+USART+PIC16F877a coding help needed  (Read 4155 times)

0 Members and 1 Guest are viewing this topic.

Offline kazamaTopic starter

  • Beginner
  • *
  • Posts: 2
  • Helpful? 0
Bluetooth+USART+PIC16F877a coding help needed
« on: September 16, 2009, 04:53:11 AM »
Hi friends. i need some help on bluetooth programming. i'm still new in bluetooth programming. i use PIC16F877a for the microcontroller and eb500 bluetooth module. i'm doing SLAM robot where i need to retrieve data from PIC memory using via bluetooth. but now i'm having some problems on bluetooth programming.

here is my code. could some help me check my coding and guide me, please. need to submit the project by 2 weeks more. i'm using CCS as the compiler.

Code: [Select]
#include <16f877a.h>
#fuses hs,nowdt,noprotect,nolvp
#use delay (clock=20000000)                 
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#byte TXSTA=0x98
#byte RCSTA=0x18
#byte SPBRG=0x99
#byte TXREG=0x19
#byte RCREG=0x1A
#byte PIR1=0x0C
#bit TXEN=TXSTA.5
#bit BRGH=TXSTA.2
#bit SYNC=TXSTA.4
#bit CREN=RCSTA.4
#bit SPEN=RCSTA.7
#bit TXIF=PIR1.4
#bit RCIF=PIR1.5
#byte portc=7
unsigned char a;

void display(unsigned char c)            // subrountine to display the text on the screen   
{
   while (TXIF == 0);
   TXREG = c;   
}

unsigned char receive(void)               // subrountine to receive text from PC
{
   while (RCIF == 0);
   a = RCREG;
   return a;
}

void init(void)                        // subroutine to initialize           
{   
   SPBRG=0x81;
   BRGH=1;
   TXEN=1;
   CREN=1;
   SPEN=1;
   SYNC=0;
   set_tris_c(0x01000000);
}

void main()
{
init();

while(true)                        // wait for 'ok' to be entered
{
a = receive();
if (a == 'd')break;
}
display('H');
}

Offline radhoo

  • Full Member
  • ***
  • Posts: 66
  • Helpful? 1
Re: Bluetooth+USART+PIC16F877a coding help needed
« Reply #1 on: September 16, 2009, 06:04:41 AM »
I've had some great success using an UART Bluetooth module. Might be a solution for you as well, since it offers 9600bps.

See: http://www.pocketmagic.net/?p=924

Regarding the module you're trying to use, do you have the datasheet?

Offline kazamaTopic starter

  • Beginner
  • *
  • Posts: 2
  • Helpful? 0
Re: Bluetooth+USART+PIC16F877a coding help needed
« Reply #2 on: September 16, 2009, 11:58:47 AM »
i have it. but it show the basic stamp programming which i didn't learn and i haven't heard the basic stamp programming. i prefer c programming and use ccs compiler. can someone guide me to finish the bluetooth connection. i want to make the bluetooth connect with pic and it can send and receive the data from pc and also pic memory.

 


Get Your Ad Here

data_list