3.1.1 Pin Setup

There are a total of nine pins that need to be configured for both the desk and door modules. However, both modules do not share all the same pins. The RA0 pin is specific to the desk module while the RB0 pin is specific to the door module. Pins RC6 and RC7 are connected internally through Peripheral Pin Select (PPS) to be the TX1 and RX1 pins, respectively. Please refer to Table 3-1 to see what parameters are enabled or disabled for each pin for this application. Pin Setup Code – Door and Desk Module and PPS Setup Code – Door and Desk Module show the pin setup code and PPS setup code, respectively, for both the desk and door modules.

Table 3-1. Pin Setup
Pin NameFunctionStart HighAnalogOutputWPUOD
RA0(1)NeoPixel Stick – Data pin--X--
RA1RN4678 Click Module – SW_RST--X--
RA3RN4678 Click Module – RTS-----
RB0(2)Cap Touch Click Board – Data pin-----
RB5RN4678 Click Module – CTS--X--
RC6RN4678 Click Module – RXD-XX--
RC7RN4678 Click Module – TXD-----
RD0RN4678 Click Module – RSTXXX--
RD1Cap Touch Click Board – Mode Pin-XX--
Note:
  1. Pin RA0 is only for the desk module.
  2. Pin RB0 is only for the door module.

Pin Setup Code – Door and Desk Module

   /**
    LATx registers
    */
    LATA = 0x0;
    LATB = 0x0;
    LATC = 0x0;
    LATD = 0x0;
    LATE = 0x0;

    /**
    TRISx registers
    */
    TRISA = 0xFC;
    TRISB = 0xDF;
    TRISC = 0xBF;
    TRISD = 0xFC;
    TRISE = 0xF;

    /**
    ANSELx registers
    */
    ANSELA = 0xFF;
    ANSELB = 0xFF;
    ANSELC = 0xFF;
    ANSELD = 0xFF;
    ANSELE = 0x7;

    /**
    WPUx registers
    */
    WPUA = 0x0;
    WPUB = 0x0;
    WPUC = 0x0;
    WPUD = 0x0;
    WPUE = 0x0;


    /**
    ODx registers
    */
   
    ODCONA = 0x0;
    ODCONB = 0x0;
    ODCONC = 0x0;
    ODCOND = 0x0;
    ODCONE = 0x0;
    /**
    SLRCONx registers
    */
    SLRCONA = 0xFF;
    SLRCONB = 0xFF;
    SLRCONC = 0xFF;
    SLRCOND = 0xFF;
    SLRCONE = 0x7;
    /**
    INLVLx registers
    */
    INLVLA = 0xFF;
    INLVLB = 0xFF;
    INLVLC = 0xFF;
    INLVLD = 0xFF;
    INLVLE = 0xF;

PPS Setup Code – Door and Desk Module

    RC6PPS = 0x0E;  //RC6->EUSART1:TX1;    
    RX1PPS = 0x17;  //RC7->EUSART1:RX1;