6.2 Configure the Application Using MCC Melody
-
Click the Device Resources tab to view the drivers and libraries available for the device. Expand the Drivers drop-down and configure the following:
- Expand the Timer drop-down and add TCB0
- Expand the UART drop-down and add UART
Figure 6-7. MPLAB® Code Configurator—Device Resources -
The peripherals added to the project will be visible in the Project Resources tab and the Application Builder view.
Figure 6-8. MPLAB® Code Configurator—Project Resources In the following steps, configure the required peripherals.
-
Configure the clock with the settings listed below by navigating to Project Resources > System > CLKCTRL:
- Clock Selection: Internal high-frequency oscillator
- Toggle off Prescaler Enable
- Write Timebase to 20
Figure 6-9. MPLAB® Code Configurator—Clock Configuration -
Configure TCB0 with the settings listed below by navigating to Project Resources > Drivers > Timer > TCB0:
- Toggle on Enable Timer
- Clock Selection: DIV1024
- Counter Size: 16BITS
- Timer Mode: INT
- Requested Timeout (s): 1
- Toggle on Generate ISR
- Toggle on Enable Capture/Timeout Interrupt
Figure 6-10. MPLAB® Code Configurator—TCB0 Configuration -
Configure UART0 with the settings listed below by navigating to Project Resources > Drivers > UART > UART0:
- Requested Baudrate: 115200
- Parity: None
- Data size: 8 bits
- Stop bits: 1 bit
- Toggle on Redirect Printf to UART
Figure 6-11. MPLAB® Code Configurator—UART Configuration -
Configure the Interrupt Controller by navigating to Project Resources > System > Interrupt Manager:
- Toggle on Global Interrupt Enable
Figure 6-12. MPLAB® Code Configurator—Interrupt Controller Configuration -
Click the Pin Grid View tab and configure the pins as shown below:
- USART0: RXD—PC2, TXD—PC1
- Pins: GPIO Input—PC0, GPIO Output—PF5
Figure 6-13. MPLAB® Code Configurator—Pin Grid View -
Configure the selected pins by navigating to Project Resources > System > Pins.
- PC0:
- Custom Name: SW0
- Enable Pull-Up
- ISC configuration: Sense Falling Edge
- PF5:
- Custom Name: LED0
- PC1:
- Enable Start High
Figure 6-14. MPLAB® Code Configurator—Pins Configuration - PC0:
