hello,
You don't need to send AT commands to your YC-MCU bluetooth device
if you use the initial factory values because SSP mode by default.
Name: linvor
code : 1234
speed: 9600,8,1,N
Simply send data to YC-MCU
but in front of PIC , on the PC computer you need to do
Appairage , autorisation to establish the connection ...
...Device fund
...Connected device
..etc...
or use and adapt to your case following this example
you can remove all LCD commands..
Code:
UART of PIC is connected to YC-MCU
Divider on TX to change Level TTL 5V to 3,3V level
UART TX ---- R=1K ---|-- RX YC-MCU
|
R=2,2K
|
-|--GND (0V)
UART RX ----------------TX YC-MCU
Code:
void Init_BT_YC_MCU()
{
LCD_putcmd(LCD_CLEAR,1); // LCD Clear
LCD_putcmd(LCD_HOME,1); // LCD Home
dummy=PutStrR_RS("AT"); // Enter command mode
LCD_putcmd(LCD_LINE1,1);
LCD_putsRom("AT> ");
dialogue=Get_reponse();
Delay10KTCYx(100); // 1 sec
dummy=PutStrR_RS("AT+NAMElinvor");// Name of device
LCD_putcmd(LCD_LINE2,1);
LCD_putsRom("NAME> ");
dialogue=Get_reponse();
Delay10KTCYx(100);
dummy=PutStrR_RS("AT+PIN1234"); // Security pin code (mikroe)
LCD_putcmd(LCD_LINE3,1);
LCD_putsRom("PIN> ");
dialogue= Get_reponse();
Delay10KTCYx(100);
dummy=PutStrR_RS("AT+BAUD4"); //9600 bauds
LCD_putcmd(LCD_LINE4,1);
LCD_putsRom("BAUD= ");
dialogue=Get_reponse();
Delay10KTCYx(1000);
}
unsigned int Get_reponse()
{ unsigned int j=0;
while((buffer[0]==0) && (j<5000))
{ Tempo(10);
j++;
}
// si pas de caractere en retour apres timeout de 20.000x0,4x10= > à 80mS
// on sort sans rien ecrire sur le LCD
if(j>= 50000)
{ LCD_putsRom("??"); // pas de reponse ou YC-MCU deja appairé
return;
}
// detection arrivee caractere OK
// pas possible de detecter un caractere specifique
// pour la fin de transmision du YC-MCU vers UART PIC
// donc on attend suffisament longtemps pour que le buffer soit remplis
// completement
Delay10KTCYx(150); // valeur 100 insuffisannte
if (buffer[0]>0)
{
buffer[i1]=0;
LCD_puts(buffer);
DataReady=0;
c1=0;
i1=0;
buffer[0]=0;
}
return j;
}
see the datasheet of YC-MCU for details of command .. change UART speed , change password 1234...
My recommandation:
At first, start by using UART + external MAX232 to debug your program
with a termianl on PC..
When terminal link is OK, you can continue with Blutooth...
and play with AT command
- - - Updated - - -
by the way...
you are NOT USING C18 Mplab !!!
because this declaration
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7, parity=N)
maybe CCS or HTC ?