yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
MSPM0G3519 Development Board📖
1. Introduction to MSPM0
  • 1. Introduction to MSPM0
2. Development environment construction
  • 1. CCS Theia Development
  • 2. MDK Arm Development
  • 3. UniFlash Downloader
  • 4. DAP-LINK download program
  • 5. Program Simulation and Debugging
  • 6. Engineering transplantation
3. Keil basic case
  • 1. Turn on the LED light
  • 2. System Delay
  • 3. Button Control
  • 4. External Interruption
  • 5. Serial Communication
  • 6. Timer
  • 7. PWM Breathing Light
  • 8. ADC Acquisition
  • 9. DMA Transfer
  • 10. Get MPU6050 data (I2C)
  • 11. LCD Display (SPI)
4. CCS basic case
  • 1. Turn on the LED light
  • 2. System Delay
  • 3. Button Control
  • 4. External Interruption
  • 5. Serial Communication
  • 6. Timer
  • 7. PWM Breathing Light
  • 8. ADC Acquisition
  • 9. DMA Transfer
  • 10. Get MPU6050 data (I2C)
  • 11. LCD Display (SPI)
5. MSPM0 Robot Expansion Board
  • 1. MSPM0 Robot Expansion Board Introduction
  • 2. Custom Buttons
  • 3. Drive Buzzer
6. MSPM0-K230Vision module application
  • 1. K230 Color Recognition
  • 2. K230 Barcode Recognition
  • 3. K230 QR Code Recognition
  • 4. K230 Apriltag Code Recognition
  • 5. K230 DM Code Recognition
  • 6. K230 Face Detection
  • 7. K230 Gaze Direction
  • 8. K230 Face Recognition
  • 9. K230 Human Body Detection
  • 10. K230 Fall Detection
  • 11. K230 Palm Detection
  • 12. K230 Gesture Recognition
  • 13. K230 OCR Character Recognition
  • 14. K230 Object Detection
  • 15. K230 Target Tracking
  • 16. K230 Self-learning Object Recognition
  • 17. K230 License Plate Recognition
7. MSPM0-K210Vision module application
  • 0. K210 Prerequisites For Making A Coprocessor - Must-see
  • 1. MSPM0_K210 Color Recognition
  • 2. MSPM0_K210 Barcode Recognition
  • 3. MSPM0_K210 QR Code Recognition
  • 4. MSPM0_K210 Mechanical Code Recognition
  • 5. MSPM0_K210 Face Detection
  • 6. MSPM0_K210 Facial Feature Detection
  • 7. MSPM0_K210 Mask Detection
  • 8. MSPM0_K210 Face Recognition
  • 9. MSPM0_K210 Object Detection
  • 10. MSPM0_K210 Self-study Classification
  • 11. MSPM0_K210 Handwritten Digit Recognition
8. Expansion case
  • 1. Autonomous Driving Car
  • 2. Vehicle-mounted Balance Ball Motion Control System
Download
  • Code
  • Hardware_Info
  • Software_Tools
Download ZIP

Welcome to MSPM0G3519 Development Board repository

2. System Delay

System Delay

System Delay1. Learning ObjectivesSysTick Timer PrincipleRole of Delay2. Hardware Setup3. Experiment Steps1. Open SYSCONFIG Configuration Tool2. SysTick Timer Configuration3. Write Program4. Compile4. Program Analysis5. Experimental Phenomena

 

1. Learning Objectives

  1. Learn the basic use of MSPM0G3519 motherboard pins.

  2. Understand the usage of the SysTick timer.

 

SysTick Timer Principle

The SysTick timer is a commonly used hardware timer used to generate fixed-cycle interrupts or trigger timing operations. Its basic working principle is to count through the main clock (MCLK) to achieve precise time intervals.

The SysTick timer is a standard timer built into the Cortex-M0 processor. As a 24-bit down counter, it has auto-reload capability and can mask system interrupts. All controllers based on the M0 core are equipped with a SysTick timer, which makes porting programs between different devices simpler. The SysTick timer is typically used in operating systems to provide necessary clock ticks for task scheduling, acting as a "heartbeat" to ensure the system executes tasks on time. Since all M0 core chips contain a SysTick timer, programs do not need to reconfigure the timer when porting, making it easier to port compared to regular timers.

In the system clock configuration, the RCU provides the external clock for the Cortex system timer (SysTick) through MCLK. By default, the MCLK frequency is 32MHz. You can control or read the timer status by setting the SysTick control and status register. For more information about the system clock, refer to the clock tree section in the user manual.

Clock Tree:

image-20241119173600015

Default Clock Path in Project:

img

The SysTick timer works as follows: After setting the initial value and enabling, each system clock cycle decrements the counter by 1. When the counter reaches 0, SysTick automatically reloads the initial value and continues counting, while setting the internal COUNTFLAG flag to 1 and triggering an interrupt (provided interrupts are enabled).

 

Role of Delay

A delay function is a function used to introduce an artificial delay in a program. Its main role is to pause the program execution for a specified time period. Simply put, the role of a delay function is to wait - essentially to wait for a period of time before executing the next code.

  • Hardware Response Waiting: Many hardware devices need a certain time to complete operations or stabilize. For example, after sending an initialization command to a display screen, if display data is sent immediately, display abnormalities may occur. Delays allow hardware sufficient time to complete initialization and ensure proper operation.

  • Implementing Timed Tasks: Delays help implement operations at fixed time intervals. For example, an automatic door controlled by a microcontroller checks infrared sensors for obstacles every 5 seconds. If no obstacle is detected, the door stays closed; if detected, the door opens and stays open for 2 seconds, then automatically closes.

  • User Interaction Optimization: In user interaction scenarios, delays can achieve better experience. For example, when a button is pressed, a delay can implement "debounce" functionality to avoid multiple triggers caused by mechanical vibration. Additionally, in status indicator light switching, delays control the blinking frequency to make the light flicker smoother and easier to observe.

 

2. Hardware Setup

This course does not require additional hardware. You can directly use the onboard LED light on the MSPM0G3519 motherboard. The previous course used imprecise delay, and this course uses SysTick timer to achieve precise delay.

We have set up two LED user lights on the motherboard. Users can customize their functions. The following uses LED1 as an example.

MSPM0G3519 Main Control Diagram

image-20241118203957884

LED Part Schematic

image-20241118204017413

3. Experiment Steps

1. Open SYSCONFIG Configuration Tool

Create a new empty project empty in CCS.

image-20241126182939655

image-20241126183128934

Find and open the empty.syscfg file in the left workspace of CCS.

image-20241127152938881

In SYSCONFIG, select MCU peripherals on the left, find the SYSTICK option and click to enter. Click ADD in SYSTICK to add the SysTick timer.

image-20241127175529577

 

2. SysTick Timer Configuration

The SysTick timer uses MCLK for timing, and MCLK is 32MHz. This means the time for each count is 1/32,000,000 = 0.00000003125 seconds. Suppose we set the count value to 32000, then the time for counting 32000 values is: 32000 x 0.00000003125 = 0.001 seconds = 1ms. Therefore, if we want to set a 1ms SysTick timer, we set the SysTick timer's count value to 32000.

image-20241127175621553

Parameter description:

Initialize Period: Initial timer period.

Period (ln McLk Cycles): Set the periodic count value. Here we set it to 32000.

Calculated Period: Time taken for counting. The software automatically calculates this value.

Enable SysTick Interrupt: Whether to enable SysTick timer interrupt.

Interrupt Priority: Select interrupt priority. Here the highest priority interrupt is selected.

Enable SysTick And start Counting: Whether to enable SysTick timer and start counting.

Save the configuration in the .syscfg file using the shortcut key Ctrl+S.

After saving, compile.

image-20241127154511315

3. Write Program

After configuring the SysTick timer, we also need to manually write the SysTick timer interrupt service function. Because we enabled the SysTick timer interrupt, when the SysTick timer's count value decrements from the set initial value to 0, it triggers an interrupt, and after triggering, it automatically executes the interrupt service function. The interrupt service function name for each interrupt is usually fixed and cannot be modified arbitrarily; otherwise, you will not be able to correctly enter the interrupt service function. The interrupt service function name is SysTick_Handler

In the empty.c file, write the following code

​x
#include "ti_msp_dl_config.h"

volatile unsigned int delay_times = 0;

//Accurate ms delay with tick timer
void delay_ms(unsigned int ms)
{
        delay_times = ms;
        while( delay_times != 0 );
}

int main(void)
{

    SYSCFG_DL_init();

    while (1)
    {
        //LED pin outputs high level
        DL_GPIO_setPins(LED1_PORT, LED1_PIN_2_PIN);
        delay_ms(1000);
        //LED pin outputs low level
        DL_GPIO_clearPins(LED1_PORT, LED1_PIN_2_PIN);
        delay_ms(1000);
    }
}

void SysTick_Handler(void)
{
        if( delay_times != 0 )
        {
                delay_times--;
        }
}

4. Compile

image-20241127155238783

Compilation was successful. You can now download the program to the development board.

4. Program Analysis

  • empty.c

image-20241127180601658

Define a global variable delay_times to record the remaining milliseconds for delay.

delay_ms(): Implements precise millisecond-level delay.

main(): After initializing the system, calls DL_GPIO_setPins to specify pins to output high/low level to control LED light on/off.

SysTick_Handler(): In the interrupt, decrements delay_times. If delay_times is non-zero, decrements it by 1 each interrupt. When it decrements to 0, the delay is complete, and the while loop in delay_ms() exits.

5. Experimental Phenomena

After the program is downloaded, you can see LED1 on the MSPM0 development board light up for 1 second and turn off for 1 second, repeatedly.

Turn on the LED light
Button Control

COMPANY

  • About us
  • Team Style
  • Blog

LEARNING & EXPLORATION

  • Tutorials
  • Edge AI hardware
  • Educational robots
  • Embedded intelligent hardware

WHERE TO BUY

  • Yahboom Online Store
  • Amazon
  • Alibaba
  • AliExpress
  • Mercado

TECHNOLOGY SUPPORT

  • Email: support@yahboom.com

BE A DISTRIBUTOR

  • Email: sales@yahboom.com
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文