Beginner Lab 10: SysTick
Objective
- Understand the working principle of the SysTick periodic timer in Arm® Cortex®-M microcontrollers.
- Measure the number of CPU cycles required to assign 250 values to an array.
- Evaluate the execution time for multiplication and division operations performed on 250 array elements.
- Analyze the performance differences between various arithmetic operations using the SysTick counter.
- Print and verify the measured execution times on the serial console via Universal Asynchronous Receiver Transmitter (UART) communication.
- Enable lab users to understand the significance of SysTick as a system timer in microcontrollers.
Overview
The SysTick timer of the PIC32CM LS00 Curiosity Nano+ Touch Evaluation Kit microcontroller is utilized as a cycle counter to measure the execution time of various arithmetic operations. In this experiment, 250 values are assigned to an array, followed by multiplication and division operations performed on the array elements. The SysTick counter is monitored before and after each operation to determine the number of clock cycles consumed. The calculated execution time is transmitted to the console using UART printf. This lab aims to analyze processor performance, instruction execution timing, and the impact of arithmetic operations on CPU cycle consumption.
Lab Activities
- Configure the SysTick system timer to count the execution cycles of CPU operations.
- Enable SERCOM3 as a USART interface to print the measured execution cycles to a terminal.
- Implement application code that utilizes the SysTick counter to measure execution time for assignment and arithmetic operations.
- Observe and verify the execution time of each operation on the terminal using the PIC32CM LS00 Curiosity Nano+ Touch Evaluation Kit.
Expected Outcomes
Upon completing this lab, you will be able to:
- Configure the SysTick timer for accurate cycle counting in Arm Cortex-M-based microcontrollers.
- Configure SERCOM3 as a USART interface to enable reliable serial communication.
- Implement embedded C code for measuring and analyzing the execution time of assignment and arithmetic operations.
- Validate and interpret execution cycle measurements using the PIC32CM LS00 Curiosity Nano+ Touch Evaluation Kit.
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: System Timer and Execution Cycles
- Step 1.1 - System Timer SysTick
- Step 1.2 - Execution Cycles for Microcontrollers
- Step 2: Configuration of SysTick Timer
- Step 2.1 - Configure SysTick Timer
- Step 2.2 - Configure SERCOM3 as USART Peripheral
- Step 2.3 - Arm TrustZone for Armv8-M
- Step 3: Generate Code
- Step 3.1 - Generate Code
- Step 4: Add Application Code to the Project
- Step 4.1 - Application Code for the Project
- Step 5: Build, Program and Observe the Output
- Step 5.1 - Build, Hardware Setup and Program
- Step 5.2 - Observe the Output