Home About Me

Getting MM32G0001 Running in Keil and Blinking the First LED

To get started with the MM32G0001, the first step is setting up a usable Keil project. Once the toolchain, device pack, and library files are in place, you can verify everything by downloading a simple LED blink program to the board.

Install the Keil device pack

Start by downloading the Keil pack for the chip family:

https://www.mindmotion.com.cn/support/software/keil_pack/

After downloading it, locate MindMotion.MM32G0001_DFP.1.0.1.pack and install it by double-clicking the file.

Keil pack installation

Get the official library files

The MM32G0001 library package is available here:

https://www.mindmotion.com.cn/products/mm32mcu/value_line/mm32g_value/mm32g0001/

Download MM32G0001 Library Functions and Examples. From that package, you need all files under the Device directory.

Then open any example project and copy out platform.c and platform.h, which will also be used in the new project.

Official library package contents

Create a new Keil project

The board used here is the FTHR-G0001, so when creating the Keil project, select MM32G0001A1TC as the target device.

Selecting the target device

When the runtime management window appears, just click OK.

Runtime environment dialog

At this point, Keil creates an empty project.

Add the required files and configure the project

Copy the files extracted from the official package into your new project folder first.

Project folder preparation

Then open Manage Project Items and add them to the project. The project structure should look like this:

Target 1
├─ APP // in the project root directory
│  └─ platform.c
├─ HAL_LIB // in \Device\MM32G0001\HAL_Lib\src
│  ├─ hal_adc.c
│  ├─ hal_crc.c
│  ├─ hal_dbg.c
│  ├─ hal_exti.c
│  ├─ hal_flash.c
│  ├─ hal_gpio.c
│  ├─ hal_i2c.c
│  ├─ hal_iwdg.c
│  ├─ hal_misc.c
│  ├─ hal_pwr.c
│  ├─ hal_rcc.c
│  ├─ hal_spi.c
│  ├─ hal_syscfg.c
│  ├─ hal_tim.c
│  ├─ hal_uid.c
│  └─ hal_usart.c
└─ STARTUP
   ├─ system_mm32g0001.c // in \Device\MM32G0001\Source
   └─ startup_mm32g0001_keil.s // in \Device\MM32G0001\Source\KEIL_StartAsm

Next, open Configure Target Options and adjust the project settings:

C/C++ tab

Make the following changes:

  • Add USE_STDPERIPH_DRIVER
  • Add the required include directories shown in the original setup

Asm tab

Set Assembler Option to armasm (Arm Syntax). This matters—if you leave it set incorrectly, the project will fail to build.

Debug tab

Change Use to CMSIS-DAP Debugger.

Then click Settings, go to the Flash Download tab, and enable Reset and Run.

With that done, the development environment is ready.

Blink the first LED

Under the APP group, create three files:

  • led.c
  • led.h
  • main.c

In led.h, include the header you need and declare the function prototypes:

#ifndef LED_H
#define LED_H
#include "hal_conf.h"
void LED_Init(void);
void LED_Toggle(unsigned int ms);
#endif // LED_H

In led.c, implement the LED initialization and toggle logic:

#include "platform.h"
#include "hal_gpio.h"
#include "hal_rcc.h"
#include "led.h"
void LED_Init(void) {
GPIO_InitTypeDef GPIO_InitStruct;
RCC_AHBPeriphClockCmd(RCC_AHBENR_GPIOA, ENABLE);
GPIO_StructInit(&GPIO_InitStruct);
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_11;
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_High;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOA, &GPIO_InitStruct);
GPIO_WriteBit(GPIOA, GPIO_Pin_11, Bit_SET);
}
void LED_Toggle(unsigned int ms) {
while(1) {
GPIO_SetBits(GPIOA, GPIO_Pin_11);
PLATFORM_DelayMS(ms);
GPIO_ResetBits(GPIOA, GPIO_Pin_11);
PLATFORM_DelayMS(ms);
}
}

In main.c, call those functions and keep the SysTick-based delay working:

#include "platform.h"
#include "led.h"
void SysTick_Handler(void) {
if (0 != PLATFORM_DelayTick) {
PLATFORM_DelayTick--;
}
}
int main(void) {
PLATFORM_Init();
LED_Init();
while(1) {
LED_Toggle(200); // 可修改亮灭频率
}
}

Build and download

Click Rebuild to compile the project. If there are no errors, the environment has been configured correctly.

After that, click Download to flash the firmware.

While programming, the board's ATS indicator will blink. Once the download finishes, LED D2 will start flashing at the delay interval you set in the code.

Project package

HelloMM32.zip

https://drive.miri.site/?/upload_api/upload_plugin/blog/HelloMM32.zip