Hi Buriedcode
Thank you for your comment.
Are you sure that the PIC's TX is connected to the BTM511's RX?
I am sure I have correct connection because I can send some character out from PIC's TX and receive some character back from BTM511.
PIC TX >>> RX BTM511
PIC RX <<< TX BTM511
PIC RTS >>> CTS BTM511
PIC CTS <<< RTS BTM511
However, the received character is weird. For example, if I sent 'a', I should get 'a' back from BTM511.
When I use the USB to UART chip (FT232) on BTM511 Evaluation Board, it works just fine. For example, if I sent 'a', I got 'a' back from BTM511.
Please see the BTM's schematic from the below link.
https://www.dropbox.com/s/5vb1yhlnulg5uz6/Board%20Schematics%20-%20BTM511.pdf?dl=0When I use PIC to send a character, I have to disable the FT232 by using jumper at J8.
However, the received character from BTM511 to PIC is weird. For example, if I sent 'a', I got 'ÿ' back from BTM511.
In the schematic, since FT232 is using DCD, DTR, DSR, RI signals, DO I NEED TO USE THESE SIGNALS?
Is the baud you set in your PIC the same as the Bluetooth module is expecting?
The baud is set to 9600 as default on BTM511 and I also set 9600 on PIC.
My MPLAB Harmony code for APP_Tasks program in app.c is below
void APP_Tasks ( void )
{
/* Check the application's current state. */
switch ( appData.state )
{
/* Application's initial state. */
case APP_STATE_INIT:
{
appData.state = APP_STATE_1;
break;
}
case APP_STATE_1:
{
if(!DRV_USART0_ReceiverBufferIsEmpty())
{
appData.rx_data1 = DRV_USART0_ReadByte();
appData.rx_data2 = DRV_USART0_ReadByte();
appData.rx_data3 = DRV_USART0_ReadByte();
appData.rx_data4 = DRV_USART0_ReadByte();
appData.rx_data5 = DRV_USART0_ReadByte();
appData.state = APP_STATE_2;
}
break;
}
case APP_STATE_2:
{
if(!DRV_USART0_ReceiverBufferIsEmpty())
{
appData.rx_data1 = DRV_USART0_ReadByte();
appData.rx_data2 = DRV_USART0_ReadByte();
appData.rx_data3 = DRV_USART0_ReadByte();
appData.rx_data4 = DRV_USART0_ReadByte();
appData.rx_data5 = DRV_USART0_ReadByte();
appData.state = APP_STATE_1;
}
break;
}
Please also see the BTM511's user guide and PIC32MX1/2/5 Starter Kit's user guide for your reference.
https://www.dropbox.com/s/m68fac23723ztf8/User%20Guide%20-%20BTM510-511%20v22.2.5.0.pdf?dl=0https://www.dropbox.com/s/x9jhitjah00xe3c/PIC32MX1XX%3A2XX%3A5XX.pdf?dl=0Hope anyone can help me.