Step 3.1: Launch MCC
Open the MCC plugin by clicking Tools > Embedded > MPLAB Code Configurator v4: Open/Close.
Or, you may click the MCC logo in the toolbar.
Use the same method to close MCC.
Note: MCC may take a while to load the first time it is launched.
Upon loading for the first time, a window will pop up to save the MCC configuration file. Click Save.
Step 3.2: Configure System Module
Now you can start configuring the settings.
For System Module, we will use the FRC Oscillator as the Clock Source which is the default configuration. In this example code, we use a faster system clock by enabling the PLL. Enable the PLL by clicking the PLL Enable checkbox.
Step 3.3 Configure GPIO
GPIO needs to be configured to drive LEDs and read switch values on the demonstration board.
In the Pin Module window, at the top right corner, select the Easy Setup tab and configure the selected GPIO as follows.
Note: The Custom Name must match the table below for the libraries to build successfully. You may copy the Custom Name from the table below and paste it into the Pin Module Custom Name fields.
|Pin Name||Function||Custom Name||Start High||Direction||Interrupt-on-change|
The Pin Module settings should look like the image below:
Step 3.4 Configure UART
Now we will add the peripherals needed for the project and configure the PAC1934 MCC library. The UART will be configured to send information to the MCP2221A Breakout Module and display data on Tera Term.
Step 3.5 Configure Timer2
Timer2 is used to maintain state machine timing.
Step 3.6 Configure SPI
SPI is used to transfer information to be displayed on the OLED W Click.
Step 3.7 Configure I2C
The I2C peripheral is used to communicate with the PAC1934 Click board. Both measurement data and control signals will be shared between the PIC24FJ256GA705 MCU and the PAC1934 metering IC using this communication channel.
Step 3.8 Configure Interrupt Priorities
It is necessary to set up the interrupt priorities to ensure concurrent resource requests are resolved in the correct order.
Step 3.9 Configure Peripheral Pins
These assignments ensure the peripherals communicate using the correct pins on the demonstration board.
In the Pin Manager: Grid View window, in the lower right window tab, lock the following Modules to their assigned pins by clicking on the blue unlock symbol to turn it to a green lock:
- SPI1: SCK1OUT to RC6
- SPI1: SDI1 to RB9
- SPI1: SDO1 to RC2
- UART1: U1RX to RB8
- UART1: U1TX to RB7
Once complete, the Pin Manager: Grid View window will look like this: