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

3. Button Control

Button Control

Button Control1. Learning Objectives2. Hardware SetupIndependent Button PrincipleButton Debouncing3. Experiment Steps1. Open SYSCONFIG Configuration Tool2. Configure Pin Mode3. Write Program4. Compile4. Program Analysis5. Experimental Phenomena

 

1. Learning Objectives

  1. Learn the basic working principle of buttons on the MSPM0G3519 motherboard.

  2. Use the button module to control the onboard LED light on/off.

 

2. Hardware Setup

Independent Button Principle

Independent buttons are typically implemented through mechanical switches. Their hardware structure consists of a button, connecting wires, and pull-up/pull-down resistors. When the button is closed, the circuit is connected and the signal level changes; when the button is released, the circuit is disconnected and the signal returns to its initial state.

 

Button Debouncing

The mechanical elasticity of buttons causes the signal to jump multiple times in a short period when closing or releasing. This is called button bouncing. It is usually eliminated through software delay debouncing or hardware RC filter circuit.

 

This course does not require additional hardware. You can directly use the onboard function button on the MSPM0G3519 development board.

In the development board schematic, the PA18 pin is connected to a button. One end of the button is connected to high level (3.3V), and the other end is connected to the GPIO pin, while also being connected to ground through a 47kΩ pull-down resistor R5. When the button is not pressed, the PA18 pin level is pulled low to 0V due to the pull-down resistor. When the button is pressed, the PA18 pin is directly connected to high level 3.3V, thereby achieving high and low level changes. The development board determines whether the button is pressed by detecting the level status of the PA18 pin. This design is simple and stable, effectively avoiding signal interference caused by floating pins.

MSPM0G3519 Main Control Diagram

image-20241118203957884

Button Part Schematic

image-20241119185237669

3. Experiment Steps

In microcontrollers, pin input mode means configuring a certain pin as an input function to receive changes in external signals. The working principle of buttons is based on this: by setting the pin connected to the button as input mode, the microcontroller can detect level changes on the pin. When the button is not pressed, the pin level remains low; when the button is pressed, the pin level becomes high. This high and low level change is the embodiment of the button input signal, and it is also the basis for the microcontroller to determine button status. Therefore, the process of receiving external signals is actually the process of detecting button high and low level changes through input mode.

1. Open SYSCONFIG Configuration Tool

Open the empty project from the SDK in KEIL.

image-20241118204605335

After selecting and opening it, open the empty.syscfg file in the KEIL interface. With the empty.syscfg file open, then open the SYSCONFIG GUI interface from the Tools menu.

image-20241118204833195

In SYSCONFIG, select MCU peripherals on the left, find the GPIO option and click to enter. Click ADD in GPIO to add a GPIO group. This GPIO_GRP_0 is the newly added one.

image-20241119191830159

 

2. Configure Pin Mode

Configure pin parameters, name the GPIO instance KEY. Since it is connected to PA18, Port selects PORTA.

Set the pin name to PIN_18, set to input mode Input. Internal Resistor sets to pull-down resistor Pull-Down Resistor. Assigned Pin sets the controlled pin to 18.

image-20241119192326266

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

image-20241119193346732

Select Yes to All in the popup.

image-20241119143728060

We also need to confirm whether ti_msp_dl_config.c and ti_msp_dl_config.h files are updated. Simply compile, and the compilation will automatically update to KEIL. If not updated, we can also copy the file content from SYSCONFIG.

3. Write Program

In the empty.c file, write the following code

​x
#include "ti_msp_dl_config.h"

int main(void)
{

        SYSCFG_DL_init();

        while (1)
        {
                // If the pin value read is greater than 0, it means that the PA18 pin is high level.
                if( DL_GPIO_readPins(KEY_PORT, KEY_PIN_18_PIN) > 0 )
                {
                        DL_GPIO_setPins(LED1_PORT,LED1_PIN_2_PIN);  //LED control output high level
                }
                else// If the PA18 pin is low
                {
                        DL_GPIO_clearPins(LED1_PORT,LED1_PIN_2_PIN);//LED control output low level
                }
        }
}

4. Compile

Click the Rebuild icon. The following prompt indicates compilation is complete with no errors.

image-20241119150803274

image-20241119150902489

4. Program Analysis

  • dl_gpio.h

xxxxxxxxxx
/**
 *  @brief      Read a group of GPIO pins
 *
 *  @param[in]  gpio  Pointer to the register overlay for the peripheral
 *  @param[in]  pins  Pins to read. Bitwise OR of @ref DL_GPIO_PIN.
 *
 *  @return     The pins (from the selection) that are currently high
 *
 *  @retval     Bitwise OR of @ref DL_GPIO_PIN of pins that are currently high
 *              from the input selection.
 */
__STATIC_INLINE uint32_t DL_GPIO_readPins(GPIO_Regs* gpio, uint32_t pins)
{
    return (gpio->DIN31_0 & pins);
}

uint32_t DL_GPIO_readPins(GPIO_Regs* gpio, uint32_t pins) is used to read the level status of specified GPIO pins. By reading the value of the GPIO register, it obtains the status of the specified pin. Input the GPIO port and pin number to read, and return the level status of that pin.

gpio: The GPIO port to read.

pins: The pin number to read.

  • empty.c

xxxxxxxxxx
int main(void)
{

        SYSCFG_DL_init();

        while (1)
        {
                // If the pin value read is greater than 0, it means that the PA18 pin is high level.
                if( DL_GPIO_readPins(KEY_PORT, KEY_PIN_18_PIN) > 0 )
                {
                        DL_GPIO_setPins(LED1_PORT,LED1_PIN_2_PIN);  //LED control output high level
                }
                else// If the PA18 pin is low
                {
                        DL_GPIO_clearPins(LED1_PORT,LED1_PIN_2_PIN);//LED control output low level
                }
        }
}

This code controls the LED by continuously detecting the level status of pin PA18 (button input pin) to control the output level of LED1_PIN_2 (LED control pin). When PA18 is high, the LED turns on (LED pin outputs high level); when PA18 is low, the LED turns off (LED pin outputs low level).

5. Experimental Phenomena

After the program is downloaded, you can control the LED light on/off with the button. Press the button, the LED turns on; release the button, the LED turns off.

image-20241119200450318

image-20241119200537063

System Delay
External Interruption

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