3.1.3 EUSART

Both the door and desk modules use the microcontroller’s EUSART to communicate with the Bluetooth Click modules. Both the microcontrollers and the Bluetooth Click modules must be configured in the same way for the communication to be successful.

For this to occur, set the EUSART parameters as follows:

  • EUSART module enabled
  • EUSART Transmit and Receive enabled
  • EUSART Asynchronous mode enabled
  • baud rate of 115200
  • 8-bit transmission and reception
  • data polarity is non-inverted
  • EUSART interrupts disabled
See EUSART Initialization Code for the full setup code for the EUSART.

EUSART Initialization Code

    // ABDEN disabled; WUE disabled; BRG16 16bit_generator; SCKP Non-Inverted; 
    BAUD1CON = 0x48;

    // ADDEN disabled; CREN enabled; SREN disabled; RX9 8-bit; SPEN enabled; 
    RC1STA = 0x90;

    // TX9D 0x0; BRGH hi_speed; SENDB sync_break_complete; SYNC asynchronous; TXEN enabled; TX9 8-bit; CSRC client; 
    TX1STA = 0x26;

    // SPBRGL 33; 
    SP1BRGL = 0x21;

    // SPBRGH 0; 
    SP1BRGH = 0x00;