yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
Wheeled Chassis Kit📖
0.Chassis installation course
  • Installation Video-1
  • Installation Video-2
  • Installation Video-3
1.4-channel motor drive module tutorials
Motor introduction and commissioning
  • 1. Motor introduction and usage
  • 2.PC host
IIC communication
  • For Arduino
  • For ESP32
  • For JetsonNANO
  • For MSPM0
  • For PICO2
  • For RDK X5
  • For RPi5
  • For STM32
USART communication
  • For Arduino
  • For ESP32
  • For JetsonNANO
  • For MSPM0
  • For PICO2
  • For RDK X5
  • For RPi5
  • For STM32
2.Kinematic analysis
  • Kinematic Analysis of Two-wheel Drive Vehicles
  • Kinematic Analysis of Four-wheel Drive Vehicles
3.MSPM0 chassis tutorials(MSPM0G3507/MSPM0G3519)
MSPM0 Basic Course
  • 1. Introduction to MSPM0
Development environment construction
  • 01.CCS Theia Development
  • 02.MDK Arm Development
  • 03.UniFlash Downloader
  • 04.DAP-LINK download program
  • 05.Program simulation and debugging
  • 06.Engineering transplantation
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)
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)
MSPM0 Robot Expansion Board Example
  • 1. Introduction to MSPM0 robot expansion board
  • 2. Customize buttons
  • 3. Drive the buzzer
MSPM0 Sensor extension information
  • 01.3-channel tracking
  • 02.4-channel tracking
  • 03.8-channel tracking
  • 04.CCD tracking
  • 05.Electric PTZ control
  • 06.2.4G handle control
  • 07.Servo ultrasonic avoid
  • 08.Bluetooth remote control
  • 09.K210-Automatic Driving
  • 10.K210-Color follow
  • 11.K210-Number recognition
  • 12.K210-Color reaction
  • 13.K210-Road signs
  • 14.K210-Machine code following
  • 15.K210-QR code recognition
  • 16.K230-Visual tracking
  • 17.K230-Color tracking
  • 18.K230-Color response
  • 19.K230-Road sign recognition
  • 20.K230-Machine code tracking
  • 21.K230-QR code recognition action
  • 22.K230-Autonomous avoid
  • 23.K230-License plate tracking
  • 24.K230-Face tracking
  • 25.K230-Gaze direction tracking
  • 26.K230-Palm tracking
  • 27.K230-Target tracking
  • 28.K230-Human body tracking
  • 29.K230-OCR character recognition action
4.STM32 chassis tutorials
  • 01.3-channel tracking
  • 02.4-channel tracking
  • 03.8-channel tracking
  • 04.CCD tracking
  • 05.Electric PTZ control
  • 06.2.4G handle control
  • 07.Servo ultrasonic avoid
  • 08.Bluetooth remote control
  • 09.K210-Automatic Driving
  • 10.K210-Color follow
  • 11.K210-Number recognition
  • 12.K210-Color Reaction
  • 13.K210-Road signs
  • 14.K210-Machine code following
  • 15.K210-QR code recognition
  • 16.K230-Visual tracking
  • 17.K230-Color tracking
  • 18.K230-Color response
  • 19.K230-Road sign recognition
  • 20.K230-Machine code tracking
  • 21.K230-QR code recognition action
  • 22.K230-Autonomous avoid
  • 23.K230-License plate tracking
  • 24.K230-Face tracking
  • 25.K230-Gaze direction tracking
  • 26.K230-Palm tracking
  • 27.K230-Target tracking
  • 28.K230-Human body tracking
  • 29.K230-OCR character recognition action
5.Expand course
  • 1.Autonomous driving car
  • 2.Vehicle-mounted balance ball motion control systemnew
Download
  • Code
  • 3D_Model_File
Download ZIP

Welcome to Wheeled Chassis Kit repository

6. Timer

Timer

Timer1. Learning ObjectivesTimerBasic parameters of the timer2. Hardware construction3. Experimental steps1. Open the SYSCONFIG configuration tool2. Timer parameter configuration3. Write the program5. Compile4. Program Analysis5. Experimental Phenomenon

1. Learning Objectives

  1. Learn the basic use of the MSPM0G3507 motherboard timer.
  2. Realize the timed flipping of LED status.

Timer

The timer is a very important peripheral in the microcontroller, used for timing and generating timed interrupts. The core principle of the timer is to record time through an internal counter. The counter is incremented by one per machine cycle. When the counter reaches a preset value, it triggers an interrupt. The program can perform certain operations in the interrupt service program, such as flipping LEDs, reading sensor data, controlling motors, etc.

Basic parameters of the timer

  1. Prescaler

The prescaler can divide the timer clock (TIMCLK) frequency by any value between 1 and 256 (1 to 256 is based on the 8-bit timer divider). TIMG can choose BUSCLK, MFCLK, LFCLK as the clock source, and can divide the clock by a maximum of 8. After passing through an 8-bit prescaler, it is finally called the timer count clock.

img

  1. Up or down counting mode

Up counting means that the counter starts counting from 0 to the auto-load value. Once the counter counts to the auto-load value, it will start counting from 0 again and generate an overflow event. Down counting means that the counter starts counting from the auto-load value to 0. Once the counter counts to 0, it will start counting from the auto-load value again and generate an underflow event.

  1. Update event

The update event is triggered when the counter overflows or underflows and starts a new counting cycle. The update event can trigger a DMA request to update the timer's operating parameters in time at the beginning of the next counting cycle, which is particularly suitable for real-time control.

2. Hardware construction

The MSPM0G series has a total of 7 timers, which can be divided into 2 types, general timers (TIMG) and advanced control timers (TIMA). Different types of timers have different numbers of functions. Generally, advanced timers have the most functions, followed by general timers.

img

3. Experimental steps

If the project needs to execute or repeat a specific task at a fixed time, the configuration of the timer is particularly important. The following will introduce how to set the timer to trigger an interrupt every 1 second, and implement the state flip of the LED in the interrupt service function, so as to achieve the effect of the LED on for 1 second and off for 1 second.

1. Open the SYSCONFIG configuration tool

Create a blank 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 TIMER option and click to enter. Click ADD in TIMER to add a timer peripheral.

image-20241127192407045

2. Timer parameter configuration

In this case, select BUSCLK-32MHz for the Timer Clock Source, select 8 for the Timer Clock Divider, and configure 100 for the Timer Clock Prescaler, so the timer frequency is 40KHz. Desired Timer Period sets the timer period to 1S, Timer Mode to period down counting mode, Enable Interrupts turns on 0 overflow interrupt. The GPIO configuration of LED is carried out according to the LED light course.

image-20241127192605312

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

3. Write the program

In the empty.c file, write the following code

​x
#include "ti_msp_dl_config.h"
​
int main(void)
{
    SYSCFG_DL_init();
    //清除定时器中断标志 Clear the timer interrupt flag
    NVIC_ClearPendingIRQ(TIMER_0_INST_INT_IRQN);
    //使能定时器中断 Enable timer interrupt
    NVIC_EnableIRQ(TIMER_0_INST_INT_IRQN);
​
    while (1)
    {
​
    }
}
​
//定时器的中断服务函数 已配置为1秒的周期
//The timer interrupt service function has been configured to a period of 1 second
void TIMER_0_INST_IRQHandler(void)
{
    //如果产生了定时器中断 If a timer interrupt occurs
    switch( DL_TimerG_getPendingInterrupt(TIMER_0_INST) )
    {
        case DL_TIMER_IIDX_ZERO://如果是0溢出中断 If it is 0 overflow interrupt
            //将LED灯的状态翻转 Flip the LED status
            DL_GPIO_togglePins(LED1_PORT, LED1_PIN_2_PIN);
            break;
​
        default://其他的定时器中断 Other timer interrupts
            break;
    }
}

5. Compile

image-20241127155238783

If the compilation is successful, you can download the program to the development board.

4. Program Analysis

  • empty.c

image-20241128090554620

This is a timer interrupt service program, which is used to handle timer overflow interrupts and perform corresponding operations. Whenever the timer overflows, the state of an LED is flipped.

5. Experimental Phenomenon

After the program is downloaded, you can see that the LED light is flashing according to the configuration of a 1-second period.

Serial communication
PWM breathing light

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/中文