Measuring Power Consumption with PAC1934 Step 4: Configure PAC193x MCC Library

Last modified by Microchip on 2023/11/09 08:59

Add PAC193x Library to MCC

Note: The PAC193x MCC library provides an easy-to-use graphical interface to configure the various options of the PAC1934 Click Board.

From the Device Resources window, expand the Pac193xLibrary folder. Add the PAC1934x Library by clicking on the + symbol for PAC193X

Device Resources PAC193X

Configure I2C Communication

Change the I2C Bus to I2C2.

Bus I2C2

Check the Overflow Alert Box.

Overflow Alert

Under the SLOW Register tab, change the Rising Edge and Falling Edge Slow pin to REFRESH. Check the Power On Reset box.

Rising Edge and Falling Edge Slow pin to REFRESH. Check the Power On Reset box

Under the Settings tab, modify the sense resistor values. The PAC1934 Click board uses 4000 uOhms value for all four channels.

PAC1934 Click board uses 4000 uOhms value for all four channel

Generate the code by clicking the Generate button in the Project Resources window. The Output window in the lower right window will read “Generation complete” if successful.

Note: MCC generates source and header files based on selections made in the GUI. The generated files are added to the active project of MPLAB X IDE.

Generate Complete Screen

Add Application Code to main.c

The main.c file needs to be modified to run the application. Open main.c file and add the API App_run() to execute the application code.

Mpen main.c file with the API App_run() added to execute the application code

Update PAC1934 Header File

Verify, and correct if necessary, the resistor value constants of the PAC1934.h file. Click on the Projects tab in the upper left corner, expand <your MPLAB X IDE project> > Header Files > MCC Generated Files > PAC1934Driver and open PAC1934.h.

Delete the semicolons on the R_SENSE_x definitions (lines 148 – 151).

Delete the semicolons on the R_SENSE_x definitions (lines 148 – 151)

Compare your MPLAB X IDE project folder structure and files with the following image:

Final Project