yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
MSPM0G3507 Development Board📖
1. Introduction to MSPM0
  • 1. Introduction to MSPM0
2. 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
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-K230 Vision Application Module
  • 1.k230 color recognition
  • 2.k230 barcode recognition
  • 3.k230 QR code recognition
  • 4.k230Apriltag code recognition
  • 5.k230DM 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.k230OCR 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.Prerequisites for K210 as a coprocessor
  • 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 casenew
  • 1.Autonomous driving car
  • 2.Vehicle-mounted balance ball motion control system
Download
  • Code
  • Hareware_Info
  • Software_Tools
  • Communication Protocol
Download ZIP

Welcome to MSPM0G3507 Development Board repository

5. Serial communication

Serial communication

Serial communication1. Learning objectivesSerial communicationSerial working mode2. Hardware Construction3. Experimental steps1. Open the SYSCONFIG configuration tool2. Serial port clock configuration3. Serial port parameter configuration4. Write the program5. Compile4. Program Analysis5. Experimental phenomenon

1. Learning objectives

  1. Learn the basic use of the serial port of the MSPM0G3507 motherboard.
  2. Understand the basic knowledge of serial communication.

Serial communication

Serial communication refers to a communication method in which data is transmitted bit by bit between peripherals and computers through data signal lines, ground lines, etc., and belongs to the serial communication method.

The key parameters of serial communication include baud rate, data bit, stop bit and parity bit. In order to ensure normal communication, these parameters must be consistent between the two communicating parties.

Serial working mode

  1. Simplex mode
  • Features: Data can only be transmitted in one direction, the sender is responsible for sending, the receiver is responsible for receiving, and there is no reverse communication.
  • Application: Applicable to scenarios where information only needs to be transmitted in one direction, such as sensor data output.
  1. Full-Duplex Mode
  • Features: Data can be transmitted in both directions at the same time, and sending and receiving do not interfere with each other.
  • Implementation: Two data lines are required, one for sending (TX) and one for receiving (RX).
  • Application: Commonly used in scenarios that require efficient and real-time communication, such as the interaction between computers and peripherals.
  1. Half-Duplex Mode
  • Features: Data is transmitted in both directions, but not at the same time, and must be sent and received alternately.
  • Implementation: Sending and receiving share a communication line, and the direction is switched by timing.
  • Application: Suitable for scenarios that do not require high real-time performance, such as walkie-talkie communication.

These three modes adapt to different communication needs and can be flexibly selected according to specific application scenarios.

2. Hardware Construction

Since the development board comes with a CH340 serial port circuit, serial port communication can be directly realized through a USB cable without an external USB to TTL module.

MSPM0G3507 main control diagram

image-20241118203957884

Type-C partial schematic diagram

image-20241120193216208

img

3. Experimental steps

This lesson uses the UART0 peripheral on the PA10 and PA11 pins, and the CH340 USB-to-serial port chip on the development board to receive serial port data sent by the host computer, and then send the data to the host computer through the serial port sending function.

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

2. Serial port clock configuration

There are three sources of serial port clock, namely:

BUSCLK: CPU clock provided by the internal high-frequency oscillator, usually the chip is set to 32MHz when it leaves the factory.

MFCLK: Only a fixed 4MHz clock can be used (refer to page 132 of the user manual). If enabled, the SYSOSC_4M branch of the clock tree needs to be configured to enable it normally.

LFCLK: The clock (32KHz) is provided by the internal low-frequency oscillator. It is valid in run, sleep, stop and standby modes. Using this clock can achieve lower power consumption.

This case uses MFCLK as the clock source of the serial port. To enable MFCLK, you need to configure the clock tree in SYSCONFIG. Find the SYSCTL option in the tab on the left side of SYSCONFIG, find Use Clock Tree in the option page and check it to enable the configuration of the clock tree.

image-20241127185442341

Click the second icon on the far left of the SYSCONFIG interface to open the clock tree.

image-20241127185637416

Turn on the MFCLK switch in the clock tree, as shown in the figure below, click the option block on the SYSOSC_4M branch to turn on the MFCLK clock. When 4.0000Mhz appears on the right, the setting is complete.

image-20241127185823906

3. Serial port parameter configuration

In SYSCONFIG, select MCU peripherals on the left, find the UART option and click Enter. Click ADD in UART to add a group of serial port peripherals.

image-20241127190015045

The configuration is consistent with the keil environment case, so it will not be explained here.

image-20241120184220043

image-20241120184904663

image-20241120185017066

image-20241120185216904

Use the shortcut keys Ctrl+S to save the configuration in the .syscfg file.

4. Write the program

After configuring the serial port, we also need to manually write the interrupt service function of the serial port. Because we have enabled the receiving interrupt of the serial port, when the serial port receives data, an interrupt will be triggered, and the interrupt service function will be executed when the interrupt is triggered. The name of the interrupt service function corresponding to each interrupt is usually fixed and cannot be modified at will, otherwise the interrupt service function will not be entered correctly. The specific name of the interrupt service function is UART0_IRQHandler.

You can also see the macro definition of the serial port 0 interrupt service function in the ti_msp_dl_config.h file we generated after compilation.

image-20241127190802568

In the empty.c file, write the following code

​x
#include "ti_msp_dl_config.h"
​
volatile unsigned int delay_times = 0;
volatile unsigned char uart_data = 0;
​
void delay_ms(unsigned int ms);
void uart0_send_char(char ch);
void uart0_send_string(char* str);
​
int main(void)
{
    SYSCFG_DL_init(); 
    //清除串口中断标志 Clear the serial port interrupt flag
    NVIC_ClearPendingIRQ(UART_0_INST_INT_IRQN);
    //使能串口中断 Enable serial port interrupt
    NVIC_EnableIRQ(UART_0_INST_INT_IRQN);
​
    while (1)
    { 
        //LED引脚输出高电平 LED pin outputs high level
        DL_GPIO_setPins(LED1_PORT, LED1_PIN_2_PIN);
        delay_ms(500);
        //LED引脚输出低电平 LED pin outputs low level
        DL_GPIO_clearPins(LED1_PORT, LED1_PIN_2_PIN);
        delay_ms(500);
    }
}
​
//搭配滴答定时器实现的精确ms延时 Accurate ms delay with tick timer
void delay_ms(unsigned int ms)
{
    delay_times = ms;
    while( delay_times != 0 );
}
//串口发送单个字符 Send a single character through the serial port
void uart0_send_char(char ch)
{
    //当串口0忙的时候等待,不忙的时候再发送传进来的字符
    // Wait when serial port 0 is busy, and send the incoming characters when it is not busy
    while( DL_UART_isBusy(UART_0_INST) == true );
    //发送单个字符 Send a single character
    DL_UART_Main_transmitData(UART_0_INST, ch);
}
//串口发送字符串 Send string via serial port
void uart0_send_string(char* str)
{
    //当前字符串地址不在结尾 并且 字符串首地址不为空
    // The current string address is not at the end and the string first address is not empty
    while(*str!=0&&str!=0)
    {
        //发送字符串首地址中的字符,并且在发送完成之后首地址自增
        // Send the characters in the first address of the string, and increment the first address after sending.
        uart0_send_char(*str++);
    }
}
​
//滴答定时器的中断服务函数 Tick ??timer interrupt service function
void SysTick_Handler(void)
{
    if( delay_times != 0 )
    {
        delay_times--;
    }
}
 
//串口的中断服务函数 Serial port interrupt service function
void UART_0_INST_IRQHandler(void)
{
    //如果产生了串口中断 If a serial port interrupt occurs
    switch( DL_UART_getPendingInterrupt(UART_0_INST) )
    {
        case DL_UART_IIDX_RX://如果是接收中断 If it is a receive interrupt
            //接发送过来的数据保存在变量中 The data sent is saved in the variable
            uart_data = DL_UART_Main_receiveData(UART_0_INST);
            //将保存的数据再发送出去 Send the saved data again
            uart0_send_char(uart_data);
            break;
​
        default://其他的串口中断 Other serial port 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-20241127191119848

Serial port interrupts must be enabled manually. The function NVIC_EnableIRQ specifies to enable a certain interrupt. Before enabling, the interrupt flag must be cleared first, otherwise the interrupt will automatically enter after enabling.

image-20241127191213557

Define two functions, uart0_send_char function sends a single character through the serial port, and uart0_send_string function sends a string through the serial port.

image-20241127191245735

UART_0_INST_IRQHandler function implements the function of receiving and returning data through the serial port. Get the interrupt type of the current UART0 through DL_UART_getPendingInterrupt(). If a UART interrupt triggered by data is received, the received data is saved in a variable and then sent out.

5. Experimental phenomenon

After the program is downloaded, you can send data to the development board through the serial port debugging assistant, and you can see the data returned by the development board.

image-20241120190513616

External interruption
Timer

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