4.1 MCC Generated Code

To generate this project using MPLAB® Code Configurator (MCC), follow the next steps:

  1. Create a new MPLAB X IDE project for PIC18F47Q10.
  2. Open MCC from the toolbar. More information on how to install the MCC plug-in can be found here.
  3. Go to Project Resources → System → System Module and do the following configuration:
    • Oscillator Select: HFINTOSC
    • HF Internal Clock: 64 MHz
    • Clock Divider: 1
    • In the Watchdog Timer Enable field in the WWDT tab, WDT Disabled has to be selected.
    • In the Programming tab, Low-Voltage Programming Enable has to be checked.
  4. From the Device Resources window, add TMR2, TMR4 and CLC1. Do the following configurations for each peripheral:
    1. Timer2 Configuration:
      • Enable Timer: checked
      • Timer Clock tab
        • Clock Source: FOSC/4
        • Prescaler: 1:128
        • Postscaler: 1:2
      • Timer Period: 4.096 ms
      • Enable Timer Interrupt: unchecked
    2. Timer4 Configuration:
      • Enable Timer: checked
      • Timer Clock tab
        • Clock Source: FOSC/4
        • Prescaler: 1:128
        • Postscaler: 1:2
      • Timer Period: 4.08 ms
      • Enable Timer Interrupt: unchecked
    3. CLC1 Configuration:
      • Enable CLC: checked
      • Mode: SR Latch
      • The SR Latch user configurable interpretation window is now available in the CLC1 window. Set the internal connections as shown below. By selecting TMR2 as clock source for the ‘S’ input and TMR4 as source for the ‘R’ input, the CLC will generate a PWM signal with 24.51 Hz frequency and variable duty cycle with steps equal to the difference between TMR2 and TMR4.
      Figure 4-3. CLC1 Configuration Mode SR Latch
  5. In the Pin Manager: Grid View window, select the I/O pins outputs to enable the internal signal access to the I/O as shown in Figure 4-4.
    Figure 4-4. Pin Mapping for the Example “Using the CLC to Create an LED Dimming Effect”
  6. In the Project Resources window, click Generate.

For this example, no extra code was used aside from the one generated from MCC.