Hello,
I have moved my Bluetooth module recently, from being controlled via an Atmel mcu to being controlled via the Diablo16, this would save me an in between step.
Anyways I have moved/ re wrote the code to work for the 4Dsystem mcu (Diablo16) and I have no luck getting the serial commands to work properly. I am already using a serial communication between the Diablo16 and and the Atmel mcu, but can't get the diablo16 to control the BT through serial.
Below is a sample of the commands that I am sending, also the serial set up and serial functions.
/////////////////////////////SETUP//////////////////////////////////////////////
pin_Set(PIN_OUT,PA1); // pin Wake_HW BT
pin_Set(PIN_OUT,PA3); //CMD/M BT
pin_Set(PIN_OUT,PA10); // Wake_SW BT
pin_Set(PIN_OUT,PA11); // BT connected BT
pin_Set(PIN_OUT,PA14); // RTS_BT BT=
pin_Set(PIN_OUT,PA15); // CTS_BT BT
COM2_TX_pin(PA9); //Serial TX1 bt
COM2_RX_pin(PA8); //Serial RX1 bt
com_SetBaud(COM2, 11520); //SET baud rate FOR COM2
com2_Init(Com_buffer2, 100, 0); //setup buffer
com2_Reset(); //reset com2
///////////////////////////Serial Functions & BT Set up////////////////////////////////////
func sendStringBluetooth(var btString)
to(BT_Buffer); putstr(btString);
putstr(BT_Buffer);
var p, a;
p := str_Ptr(BT_Buffer);
for(i := 0; i < 100; i++) //loop to write every character to var
a := (str_GetByte(p + i));
sendCharBluetooth(a);
next
endfunc
func sendCharBluetooth(var btChar)
serout2(btChar);
pause(10);
endfunc
func BTFactoryReset()
pin_HI(PA10);
for(i := 0; i < 3; i++)
pin_HI(PA1);
pause(100);
pin_LO(PA1);
pause(100);
next
pin_HI(PA1);
pause(100);
pin_LO(PA1);
endfunc
func BTWake()
pin_HI(PA1);
pin_HI(PA10);
pause(100);
pin_LO(PA1);
endfunc
/////////////////////////////////Command Functions///////////////////////////
func bluetoothTest()
to(BT_Command); putstr("+\r\n");
sendStringBluetooth(BT_Command);
pause(500);
to(BT_Command); putstr("SF,1\r\n");
sendStringBluetooth(BT_Command);
pause(500);
to(BT_Command); putstr("SS,C0000000\r\n");
sendStringBluetooth(BT_Command);
pause(500);
to(BT_Command); putstr("SR,92000000\r\n");
sendStringBluetooth(BT_Command);
pause(500);
to(BT_Command); putstr("SN,TestName\r\n");
sendStringBluetooth(BT_Command);
pause(500);
to(BT_Command); putstr("R,1\r\n");
sendStringBluetooth(BT_Command);
pause(500);
endfunc
/////////////////////////Application//////////////////////////////////////////
BTWake();
pause(500);
BTFactoryReset();
pause(500);
bluetoothTest();
The way I am currently testing to see if the commands got through is to search for the device with an app from microchip and see if the given name comes up (TestName) or simply RN####, I don't know if this is the best way but what I am doing.
Would appreciate any help from the community, let me know if anything is unclear or if you need more details.
Thanks,
Navid
I have moved my Bluetooth module recently, from being controlled via an Atmel mcu to being controlled via the Diablo16, this would save me an in between step.
Anyways I have moved/ re wrote the code to work for the 4Dsystem mcu (Diablo16) and I have no luck getting the serial commands to work properly. I am already using a serial communication between the Diablo16 and and the Atmel mcu, but can't get the diablo16 to control the BT through serial.
Below is a sample of the commands that I am sending, also the serial set up and serial functions.
/////////////////////////////SETUP//////////////////////////////////////////////
pin_Set(PIN_OUT,PA1); // pin Wake_HW BT
pin_Set(PIN_OUT,PA3); //CMD/M BT
pin_Set(PIN_OUT,PA10); // Wake_SW BT
pin_Set(PIN_OUT,PA11); // BT connected BT
pin_Set(PIN_OUT,PA14); // RTS_BT BT=
pin_Set(PIN_OUT,PA15); // CTS_BT BT
COM2_TX_pin(PA9); //Serial TX1 bt
COM2_RX_pin(PA8); //Serial RX1 bt
com_SetBaud(COM2, 11520); //SET baud rate FOR COM2
com2_Init(Com_buffer2, 100, 0); //setup buffer
com2_Reset(); //reset com2
///////////////////////////Serial Functions & BT Set up////////////////////////////////////
func sendStringBluetooth(var btString)
to(BT_Buffer); putstr(btString);
putstr(BT_Buffer);
var p, a;
p := str_Ptr(BT_Buffer);
for(i := 0; i < 100; i++) //loop to write every character to var
a := (str_GetByte(p + i));
sendCharBluetooth(a);
next
endfunc
func sendCharBluetooth(var btChar)
serout2(btChar);
pause(10);
endfunc
func BTFactoryReset()
pin_HI(PA10);
for(i := 0; i < 3; i++)
pin_HI(PA1);
pause(100);
pin_LO(PA1);
pause(100);
next
pin_HI(PA1);
pause(100);
pin_LO(PA1);
endfunc
func BTWake()
pin_HI(PA1);
pin_HI(PA10);
pause(100);
pin_LO(PA1);
endfunc
/////////////////////////////////Command Functions///////////////////////////
func bluetoothTest()
to(BT_Command); putstr("+\r\n");
sendStringBluetooth(BT_Command);
pause(500);
to(BT_Command); putstr("SF,1\r\n");
sendStringBluetooth(BT_Command);
pause(500);
to(BT_Command); putstr("SS,C0000000\r\n");
sendStringBluetooth(BT_Command);
pause(500);
to(BT_Command); putstr("SR,92000000\r\n");
sendStringBluetooth(BT_Command);
pause(500);
to(BT_Command); putstr("SN,TestName\r\n");
sendStringBluetooth(BT_Command);
pause(500);
to(BT_Command); putstr("R,1\r\n");
sendStringBluetooth(BT_Command);
pause(500);
endfunc
/////////////////////////Application//////////////////////////////////////////
BTWake();
pause(500);
BTFactoryReset();
pause(500);
bluetoothTest();
The way I am currently testing to see if the commands got through is to search for the device with an app from microchip and see if the given name comes up (TestName) or simply RN####, I don't know if this is the best way but what I am doing.
Would appreciate any help from the community, let me know if anything is unclear or if you need more details.
Thanks,
Navid
Comment