0

I am using the PIC32MX795F512H device together with the RN42 bluetooth module both from Microchip.

I am noticing a weird behavior. From this C code snippet:

    secs = G_CLOCK;
    while(G_CLOCK-secs<300);  // delay 300 ms
    UART3WriteString("$$$");
    secs = G_CLOCK;
    while(G_CLOCK-secs<300);  // delay 300 ms
    UART3WriteString("gf\r\n");
    secs = G_CLOCK;
    while(G_CLOCK-secs<300);  // delay 300 ms
    strcpy(privData->btmac,result);
    UART3WriteString("---\r\n");
    secs = G_CLOCK;
    while(G_CLOCK-secs<600);  // delay 600 ms
    UART3WriteString("Test 123\r\n");
    UART3WriteString("Test 456\r\n");
    UART3WriteString("Test 789\r\n");
    UART3WriteString("Test abc\r\n");

Then I receive this ouptut:

Test 123 
Test 456 
Test 789 
Test abc

CMD

50B7C3F7033A

END

The weird thing here is all the last 4 prints actually were outputted in the beginning. So what actually happened first? Was it the entering of command mode with the GF command? Or was it the 4 "Test xxxx" UART3WriteString commands?

Thanks

Renato
  • 178
  • 1
  • 13
  • The $$$ command is missing newline \r\n, so it could be something else entering it into cmd mode. Check by testing each part independently, see what the result is. Or program a button so that a button press sends the next string. – imqqmi May 25 '17 at 12:48
  • It's not supposed to have a newline. All is needed is the $$$. Unfortunately I don't have access to a button! – Renato May 25 '17 at 13:01
  • Add a loop after each write checking the TXBUF Full on the UART3 module. while(U3STAbits.UTXB); Also, are you using interrupts at all? Also do you have a schematic? – blsmit5728 May 25 '17 at 14:36

0 Answers0