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.
#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');
}