Step 6: Configure MCU2 Resources with MCC

Step 6.1 - Launch MCC

1

Open MPLAB® Code Configurator (MCC) by clicking the MCC logo in the MPLAB X Integrated Development Environment (IDE) toolbar.

MCC-Open-Close.png

Step 6.2 - Configure System Module

Now you can start configuring the settings for MCU2.

1

Click on System Module in the Project Resources window.

8-bit-PIC-DMA9a.png

2

As before, we will use the HFINTOSC Oscillator for the clock source.

8-bit-PIC-DMA10b.png

Step 6.3 – Configure PWM

Now we will add the Core Independent Peripherals (CIPs) needed to the project and configure them. The PWM is used to control the LED brightness with its duty cycle value.

1

Add PWM by opening the PWM folder under Device Resources window and clicking the + icon for PWM1_16BIT.

8-bit-PIC-DMA30a.png

2

Select the PWM1_16BIT CIP in the Project Resources window to configure its settings:

8-bit-PIC-DMA32b.png

3

Make necessary changes to the PWM configuration window to match the following settings:

  • Enable PWM: Check
  • Clock Selection: FOSC
  • Clock Prescaler: 0
  • Mode: Left aligned mode
  • Requested Frequency: 1 kHz
  • Output1 Duty Cycle (%): 50
  • Output2 Duty Cycle (%): 50
8-bit-PIC-DMA33.png

Step 6.4 – Configure UART

The UART is used to receive the ADC results.

1

Open the UART folder in the Device Resources window and click on the + icon for UART3.

8-bit-PIC-DMA31a.png

2

Open the UART3 setting by clicking UART3 in the Project Resources window.

8-bit-PIC-DMA33a.png

3

Configure UART3 for the following settings:

  • Mode: Asynchronous 8-bit mode
  • Enable UART: Check
  • Enable Transmit: Check
  • Enable Receive: Check
  • Baud Rate: 9600
  • Transmit Polarity: not inverted
  • Receive Polarity: not inverted
8-bit-PIC-DMA34.png

Step 6.5 – Configure GPIO

GPIO will be configured to output the PWM waveform and to receive UART data.

1

Select Pin Manager: Grid View in the bottom right window. Click each pin with a green lock as either an input or output as shown in the figure below:

8-bit-PIC-DMA35.png

Step 6.6 – Configure DMA

The DMA is used to transfer the UART receive buffer contents to the PWM duty cycle register

1

Select DMA Manager from the Project Resources window.

DMA_PR.png

2

Update the DMA configuration window as follows:

  • DMA Channel 1 Box: Check
  • Source Module: UART3
  • Source Region: SFR
  • Source SFR: U3RXB
  • Source Mode: unchanged
  • Source Message Size: 1
8-bit-PIC-DMA36.png

3

Continue to update the DMA configuration window as follows:

  • Destination Module: PWM1_16BIT
  • Destination Region: SFR
  • Destination SFR: PWM1S1P1L
  • Destination Mode: incremented
  • Destination Message Size: 2
  • Start Trigger: U3RX
8-bit-PIC-DMA37.png

Step 6.7 – Update PWM Settings

The PWM needs to be assigned to DMA Channel 1.

1

Select the PWM1_16BIT CIP from the Project Resources window again.

8-bit-PIC-DMA32b.png

2

Open the UART3 setting by clicking UART3 in the Project Resources window.

LDS.png

Step 6.8 - Generate MCC Code

1

Press the Generate button.

8-bit-PIC-DMA25.png

2

Verify the MCC code generation is successful.

8-bit-PIC-DMA27.png
© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.