Beginner Lab 4: Clock System Configuration
Last modified by Microchip on 2026/06/26 07:35
Objective
- The objective of this laboratory exercise is to understand the microcontroller clock system, including oscillators, the Phase-Locked Loop (PLL), Generic Clock Controller (GCLK), Digital Frequency Locked Loop (DFLL), main clock and peripheral clock distribution.
- This lab will demonstrate how different clock sources impact system timing and peripheral performance.
- Perform this exercise using MPLAB® X IDE as the development environment and the PIC32CM LS00 Curiosity Nano+ Touch Evaluation Kit as the hardware platform.
Overview
This lab introduces the clock system architecture of a microcontroller, emphasizing the roles of the oscillator, PLL, GCLK, DFLL, main clock and peripheral clock distribution. The exercise starts by exploring various clock sources, specifically comparing the internal oscillator with an external crystal. It examines how each source influences system stability and accuracy, using MPLAB X IDE on the PIC32CM LS00 Curiosity Nano+ Touch Evaluation Kit.
Lab Activities
- Configure the SysTick timer using the configuration options and configure an LED using the pin configuration in MPLAB X IDE.
- Configure the clock system to use the internal oscillator and verify the system clock settings.
- Reconfigure the clock system to use an external crystal oscillator to generate the clock frequency.
- Add the application code to the generated project to toggle the LED using a SysTick timer-based delay.
- Observe and compare the effect of internal and external clock sources on SysTick timing accuracy by connecting Logic Analyzer Channel 0 to the LED output pin.
Expected Outcomes
Upon completion of this lab, you will be able to:
- Configure the SysTick timer and General Purpose Input/Output (GPIO) pins using the available configuration options in MPLAB X IDE.
- Set up and verify the system clock operation using both the internal oscillator and an external crystal oscillator as clock sources.
- Implement delays based on the SysTick timer to control LED toggling through application code.
- Measure and analyze the timing accuracy of the SysTick timer on the PIC32CM LS00 Curiosity Nano+ Touch Evaluation Kit using a logic analyzer with both internal and external clock sources.
- Compare the performance and accuracy of internal and external clock sources, and evaluate their impact on overall system timing behavior.
Lab Source Files and Solutions
This ZIP file contains the completed solution project for this lab. It also contains the source files needed to perform the lab as per the following step-by-step instructions (see the "Lab Index" section on this page).
for this lab.
Lab Index
- Step 1: Microcontroller Clock System Components
- Step 1.1 - Oscillator
- Step 1.2 - Phase Locked Loop (PLL)
- Step 1.3 - Peripheral Clock Distribution
- Step 2: Configure SysTick Timer and LED
- Step 2.1 - Configure SysTick timer to generate delay
- Step 2.2 - Pin Configuration for LED
- Step 3: Internal and External Clock Configuration
- Step 3.1 - Internal Clock Configuration
- Step 3.2 - External Clock Configuration
- Step 4: Generate Code
- Step 4.1 - Generate Code
- Step 5: Add Application Code to the Project
- Step 5.1 - Application code for the project
- Step 6: Build, Program and Observe the Output
- Step 6.1 - Build, hardware setup, and program
- Step 6.2 - Observe the Output for Internal clock
- Step 6.3 - Observe the Output for External clock
- Step 6.4 - Differential Behavior