yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
MSPM0 Smart Robot Car📖
1.Quick Start Guide
  • 1. Assembly Videos
  • 2. Quick Start Videos
  • 3. Battery charging
  • 4. Notes
2.Introduction to the MSPM0 Car
  • 1.About MSPM0
  • 2.Development board interface description
3.Development environment setup and usage
  • 1.CCS Theia development
  • 2.MDK Arm development
  • 3.Uniflash burning
  • 4.External crystal oscillator configuration
  • 5.Project Migration
4.MSPM0 basic course
  • 1. LED light control (GPIO)
  • 2. Buzzer Control (GPIO)
  • 3. Button Control (EXTI)
  • 4. Serial Port (UART)
  • 5. Voltage Detection (ADC)
  • 6. Temperature Detection (ADC)
  • 7. Independent Watchdog (WWDG)
  • 8. Window Watchdog (WWDG)
  • 9. Timer (TIM)
  • 10. Breathing LED (PWM)
  • 11. I2C Communication (I2C)
  • 12. External Flash (SPI)
  • 13. Internal Flash (Flash)
  • 14. DMA
  • 15. FreeRTOS
5.Sensor basic course
  • 1.Servo control
  • 2.Ultrasonic servo PTZ basic use
  • 3.Motor PID control
  • 4.OLED display photosensitive value
  • 5.Infrared avoid sensor
  • 6.1 Infrared line tracking sensor-8 channel infrared tracking sensor module
  • 6.2 Infrared line tracking sensor-4 channel infrared tracking sensor module
  • 7.Infrared remote control
  • 8.Ultrasonic ranging
  • 9.RGB light drive
  • 10.MPU6050 raw data acquisition
  • 11.MPU6050 data fusion
  • 12.K210 vision recognition module
  • 13.K230 vision recognition module
6.Smart car course
  • 1.1 Car line tracking-8 channel infrared tracking sensor module
  • 1.2 Car line tracking-4 channel infrared tracking sensor module
  • 2.1 Drawing a circle-8 channel infrared tracking sensor module
  • 2.2 Drawing a circle-4 channel infrared tracking sensor module
  • 3.Ultrasonic following
  • 4.Ultrasonic avoid
  • 5.Ultrasonic avoid(Servo PTZ)
  • 6.Infrared sensor avoid
  • 7.Light following
  • 8.Gyroscope calibration straight-line walk
  • 9.Infrared remote control
  • 10.Autonomous driving car
7.Vision application course
  • 1.K210 autonomous driving
  • 2.K210 color tracking
  • 3.K210 handwritten digit action
  • 4.K210 color response
  • 5.K210 road sign indication action
  • 6.K210 following machine code
  • 7.K210 QR code command
  • 8.K230 vision line tracking
  • 9.K230 color tracking
  • 10.K230 machine code tracking
  • 11.K230 QR code command
  • 12.K230 autonomous avoid
  • 13.K230 license plate tracking
  • 14.K230 face tracking
  • 15.K230 gaze direction tracking
  • 16.K230 palm tracking
  • 17.K230 target tracking
  • 18.K230 human body tracking
  • 19.K230 OCR character recognition
8.Extended application course (Sold separately)
  • 1.Voice interaction module communication
  • 2.Voice interaction control
  • 3.K230 road sign indication action(Voice)
  • 4.K230 color response(Voice)
  • 5.K230 gesture control(Voice)
  • 6.K230 rock-paper-scissors(Voice)
  • 7.8-channel grayscale color line tracking
  • 8.Bluetooth remote control
  • 9.K210 Scenario-based autonomous driving
  • 10.K230 Scenario-based autonomous driving
Download
  • Code
  • SCH
  • 3D Model File
  • MSPM0 Data Sheet
  • Voice firmware
  • Hardware interface manual
Download ZIP

Welcome to MSPM0 Smart Robot Car repository

2. Buzzer Control (GPIO)

Buzzer Control

Buzzer ControlI. Learning ObjectivesII. Hardware SetupIII. Experiment Steps1. Open SYSCONFIG Configuration Tool2. Parameter Settings2.1 Set Port Parameters2.3 Save and Update Configuration File3. Write Program4. CompileIV. Program AnalysisV. Experiment Phenomenon

 

I. Learning Objectives

  1. Learn the basic usage of MSPM0G3507 development board pins.
  2. Understand how to control the onboard active buzzer.

II. Hardware Setup

This course requires no additional hardware devices, directly using the onboard buzzer on the MSPM0G3507 development board.

MSPM0G3507 Main Control Diagram

image-20251011182746790

Buzzer Part Circuit Diagram

image-20251011182807826

III. Experiment Steps

1. Open SYSCONFIG Configuration Tool

In KEIL, open the empty project from the SDK. After selecting and opening, in the KEIL interface, open the empty.syscfg file. With the empty.syscfg file open, select Open SYSCONFIG GUI interface from the Tools menu.

image-20251010121413002

image-20251010121515500

We first enable SWD debugging so that we can use debugging tools (DAP-Link, Jlink) to burn and debug the project.

image-20251010121743860

We need to enable the SYSTICK clock for delay, set it to 1us here. Whether to enable SYSTICK interrupt depends on needs, it is disabled by default here (the period can be adjusted according to the clock tree configuration).

image-20251010143140013

 

2. Parameter Settings

2.1 Set Port Parameters

In SYSCONFIG, select MCU peripherals on the left, find GPIO option and click to enter. In GPIO, click ADD to add a GPIO group, the name can be customized, here it is BEEP.

Set GPIO parameters, name this pin as OUT

From the buzzer part circuit diagram, we can see that the buzzer is located on port PB5, so set Port to PORTB.

image-20251011183013682

Parameter Description:

Name: Custom name for the GPIO instance. By default, the name starts with numeric suffix "0"; we can customize the name to reflect the module purpose (for example, naming GPIO as "MCU", so we know this pin is specifically for controlling LED_MCU).

Initial Value: Configure the initial level of GPIO, can only be set when configured as output mode. Here it is set to Cleared, default low level. High level is (Set)

Direction: Configure GPIO input/output, here it is output Output, Input is optional

Port: The port where the GPIO instance is located. Buzzer is connected to GPIOB pin, can only select PORTB.

Port Segment: Set port pull-up/pull-down resistor. Note that this is port pull-up/pull-down, setting the entire GPIOB port.

IO Structure: Set IO structure. There are multiple options, default (Any), standard (Standard), wake-up (Standard with Wake), high-speed (High-Speed) and 5V tolerant (5V Tolerant Open Drain) structures.

Internal Resistor: Set pin pull-up/pull-down resistor. There are three options, no setting, set pull-up and set pull-down resistor. Here according to the buzzer connection, pull-down resistor is selected.

Assigned Pin: Set pin number. To control which pin, fill in the corresponding pin number, for example, the buzzer on the development board is connected to GPIOB5, then fill in 5.

2.3 Save and Update Configuration File

Click SAVE to save the configuration in SYSCONFIG, then close SYSCONFIG and return to keil.

image-20251010122648549

Select Yes to All in the pop-up window

image-20241119143728060

After that, we can see that the empty.syscfg file has been updated with our set parameters.

We also need to confirm whether ti_msp_dl_config.c and ti_msp_dl_config.h files are updated. Directly compile, compilation will automatically update to keil. If not updated, we manually select the project path to save

image-20251010122909973

Relative path as follows image-20251010123041227

3. Write Program

In the empty.c file, write the following code

​x
#include "ti_msp_dl_config.h"
#include "beep.h"
#include "delay.h"
​
int main(void)
{
    SYSCFG_DL_init();
    
​
    while (1)
    {
        //Buzzer starts for 200ms then stops for 200ms
        Beep_ON();                 
        delay_ms(200);
        Beep_OFF();
        delay_ms(200);
    }
        
}

beep.c

xxxxxxxxxx
​
void Beep_ON(void)
{
    DL_GPIO_setPins(BEEP_PORT,BEEP_OUT_PIN);
​
}
​
void Beep_OFF(void)
{
    DL_GPIO_clearPins(BEEP_PORT,BEEP_OUT_PIN);
​
}

delay.c

xxxxxxxxxx
#include "ti_msp_dl_config.h"
//Using method 0, 1 to implement delay requires disabling systick interrupt  
//The following implements delay using three methods: 0: using a loop of no operations to implement delay 1: using polling to read systick count to implement delay  2: using systick interrupt to implement delay (default) If using the first two methods, disable systick interrupt 
​
#define DELAY_SELECT 1
volatile unsigned int delay_times = 0;
​
​
//Custom delay (not precise) 
#if DELAY_SELECT==0
void delay_ms(unsigned int ms)
{
    unsigned int i, j;
    // The number of nested loops below is roughly calculated based on the main control frequency and the instruction cycle generated by the compiler,
    // and needs to be adjusted through actual testing to achieve the required delay.
   
    for (i = 0; i < ms; i++)
    {
        for (j = 0; j < 8000; j++) 
        {
            // Only execute a simple operation that can predict its execution time
            // "nop" represents "no operation", which consumes one or several clock cycles in most architectures, not fixed 
            __asm__("nop"); 
        }
    }
}
​
#elif  DELAY_SELECT==1
//Implement delay by polling systick count 
void delay_us(unsigned long __us) 
{
    uint32_t ticks;
    uint32_t told, tnow, tcnt = 0;
​
    ticks = __us * (80000000 / 1000000);  
    told = SysTick->VAL;
​
    while (1)
    {
        tnow = SysTick->VAL;
        if (tnow != told)
        {
            if (tnow < told)
                tcnt += told - tnow;
            else
                tcnt += (SysTick->LOAD + 1) - tnow + told;
​
            told = tnow;
            if (tcnt >= ticks)
                break;
        }
    }
}
//Precise ms delay implemented with tick timer 
void delay_ms(unsigned long ms) 
{
    while (ms--)
    {
        delay_us(1000);  
    }
}
                
#else
//Implement delay using systick interrupt, need to enable systick interrupt in sysconfig  
void delay_ms(unsigned int ms)
{
    delay_times=ms;
    while(delay_times!=0);
}
​
​
void SysTick_Handler(void)
{
        if( delay_times != 0 )
        {
                delay_times--;
        }
}
#endif
​

4. Compile

Click the Rebuild icon. The following prompt indicates that compilation is complete and there are no errors.

image-20251010123217887

image-20241119150902489

IV. Program Analysis

  • dl_gpio.h
xxxxxxxxxx
/**
 *  @brief      Set a group of GPIO pins
 *
 *  @param[in]  gpio  Pointer to the register overlay for the peripheral
 *  @param[in]  pins  Pins to set high. Bitwise OR of @ref DL_GPIO_PIN.
 */
__STATIC_INLINE void DL_GPIO_setPins(GPIO_Regs* gpio, uint32_t pins)
{
    gpio->DOUTSET31_0 = pins;
}
​
/**
 *  @brief      Clear a group of GPIO pins
 *
 *  @param[in]  gpio  Pointer to the register overlay for the peripheral
 *  @param[in]  pins  Pins to clear. Bitwise OR of @ref DL_GPIO_PIN.
 */
__STATIC_INLINE void DL_GPIO_clearPins(GPIO_Regs* gpio, uint32_t pins)
{
    gpio->DOUTCLR31_0 = pins;
}
​
/**
 *  @brief      Toggle a group of GPIO pins
 *
 *  @param[in]  gpio  Pointer to the register overlay for the peripheral
 *  @param[in]  pins  Pins to toggle. Bitwise OR of @ref DL_GPIO_PIN.
 */
__STATIC_INLINE void DL_GPIO_togglePins(GPIO_Regs* gpio, uint32_t pins)
{
    gpio->DOUTTGL31_0 = pins;
}

__STATIC_INLINE void DL_GPIO_setPins(GPIO_Regs* gpio, uint32_t pins): This function controls the pin to output high level.

__STATIC_INLINE void DL_GPIO_clearPins(GPIO_Regs* gpio, uint32_t pins): This function controls the pin to output low level.

__STATIC_INLINE void DL_GPIO_togglePins(GPIO_Regs* gpio, uint32_t pins): This function controls the pin level toggle, if it was high level it becomes low level, if it was low level it becomes high level.

V. Experiment Phenomenon

After the program download is complete, you can see the buzzer on the MSPM0 development board starts for 200ms then stops for 200ms.

 

LED light control (GPIO)
Button Control (EXTI)

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