Hezhou Air001 Development Board Series Tutorial—01 Environment Construction and Lighting (Development Based on Keil-MDK)

insert image description here
  Recently, Hezhou has produced a:

TSSOP20封装、ARM®Cortex®-M0+内核,内置32K Flash+4K RAM、集成多路USART、IIC、SPI等通讯外设,516bit定时器以及112bit ADC和2路比较器的国产MCU

  10 yuan for a development board + 10 chips, the cost performance is still very high, and its "unique" packaging appearance, I immediately started to try it out.

1. Introduction

  This series of tutorials is completely in accordance with the official document tutorials, except that the operation steps are recorded more specifically, as well as the problems encountered and solutions. If you need to directly view the official documents, click →: Air001 Chip Environment Construction
  Tutorial The development method based on KEIL-MDK is the main method. If you need to develop with Arduino IDE, you can refer to the official document: Air001 Chip Environment-Arduino Build Tutorial

1. Environment construction

1. Download SDK

  Here, by default, everyone has installed keil MDK and completed the registration and activation. First, download and install the SDK of the Air001 chip: Air001 SDK download【OpenLuat Gitee】

insert image description here

Unzip the downloaded file and go into the PACK folder:
insert image description here

2. Install PACK

Double-click to open the .pack file for installation:
insert image description here

Click NEXT to complete the installation
insert image description here

3. Create a new Keil project

Open Keil, click "Project" - "New μVison Project"
insert image description here

Then click OK after selecting an appropriate location and name:
insert image description here

Select the Air001 chip in the pop-up window, and click "OK":
insert image description here

In the pop-up window, check "CORE" in "CMSIS" and "Stratup" in "Device", and then click "OK":
insert image description here

4. Configure Keil project

(1) Copy the HAL library

Copy the AIR001xx_HAL_Driver folder under the Libraries directory in the SDK folder to the project directory:
insert image description here

insert image description here

(2) Add C file reference

Go back to Keil software, add HAL library peripheral source files to the project, follow the steps shown in the figure, and finally select "\Libraries\AIR001xx_HAL_Driver\Src"

  • “air001xx_hal.c”
  • “air001xx_hal_rcc.c”
  • “air001xx_hal_rcc_ex.c”
  • “air001xx_hal_cortex.c”
  • “air001xx_hal_gpio.c”
  • “air001xx_hal_pwr.c”
  • “air001xx_hal_pwr_ex.c”
  • “air001xx_hal_flash.c”

Finish adding:
insert image description here

(3) Create a new main.c

First create a main.c file
insert image description here

insert image description here

The file content is left blank first.

(4) Create new air001xx_hal_conf.h

Create an "air001xx_hal_conf.h" file to configure the HAL library:
insert image description here

The supplementary code is:

#ifndef __AIR001xx_HAL_CONF_DEFAULT_H
#define __AIR001xx_HAL_CONF_DEFAULT_H

#ifdef __cplusplus
extern "C" {
#endif

#define HAL_MODULE_ENABLED
#define HAL_GPIO_MODULE_ENABLED
#define HAL_RCC_MODULE_ENABLED
#define HAL_FLASH_MODULE_ENABLED
#define HAL_PWR_MODULE_ENABLED
#define HAL_CORTEX_MODULE_ENABLED

#define HSE_VALUE            8000000U  
#define HSE_STARTUP_TIMEOUT  100U      
#define HSI_VALUE            24000000U 
#define HSI_STARTUP_TIMEOUT  5000U     
#define LSI_VALUE            32000U
#define LSE_VALUE            32768U    /*!< Value of the External Low Speed oscillator in Hz */
#define LSE_STARTUP_TIMEOUT  5000U     /*!< Time out for LSE start up, in ms */
#define  TICK_INT_PRIORITY            0x00U /*!< tick interrupt priority */


#include "air001xx_hal_rcc.h"
#include "air001xx_hal_gpio.h"
#include "air001xx_hal_flash.h"
#include "air001xx_hal_pwr.h"
#include "air001xx_hal_cortex.h"

#define assert_param(expr) ((void)0U)

#endif

The above content is also derived from the code content in the official tutorial:
insert image description here

After supplementing the figure below, the statement marked in red is because the header file has not yet added the relevant file path, and it will be added later:
insert image description here

(5) Create new air001xx_it.h

Create a new air001xx_it.h header file to implement the interrupt function. Same as above, create a new file "air001xx_it.h":
insert image description here

Code content:

#ifndef __AIR001XX_IT_H
#define __AIR001XX_IT_H

#ifdef __cplusplus
 extern "C" {
#endif 
void NMI_Handler(void);
void HardFault_Handler(void);
void SVC_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);

#ifdef __cplusplus
}
#endif
#endif

insert image description here

(6) Create new air001xx_it.c

The same operation, create a new "air001xx_it.c" file:
insert image description here

#include "air001xx_it.h"
void NMI_Handler(void)
{
}

void HardFault_Handler(void)
{
  while (1)
  {
  }
}

void SVC_Handler(void)
{
}

void PendSV_Handler(void)
{
}

void SysTick_Handler(void)
{
  HAL_IncTick();
}

insert image description here

(7) Add header file path

Next, start to add the path, first click "Options for Target", which is the "magic wand"
insert image description here

Then select the extension button on the right of "C/C++" – "Includes Paths":
insert image description here

Add the following paths, and finally click "OK":
insert image description here

(8) Add macro definition

Add the macro definition "AIR001_DEV" and click "OK"
insert image description here

Supplement the file content of main.c:

#include "air001xx_hal.h"

int main(void)
{
	HAL_Init();
	GPIO_InitTypeDef GPIO_LED = {
		.Pin = GPIO_PIN_0,
		.Mode = GPIO_MODE_OUTPUT_PP,
	};
	__HAL_RCC_GPIOB_CLK_ENABLE();
	HAL_GPIO_Init(GPIOB, &GPIO_LED);

	while (1)
	{
		HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_0);
		HAL_Delay(500);
	}
}

(9) compile

Here you can try to compile, please pay attention before compiling, the C compiler chooses Compiler Version 5, Keil MDK 5.37 and later versions are all version 6 by default, you need to manually install Compiler Version 5 (https://developer. arm.com/downloads/view/ACOMP5 [registration\login required]:
insert image description here

I have a small problem when compiling here:
insert image description here

This function is weakly defined in "air001xx_hal.h". I don't know if it is my operation problem or I missed the steps of the official tutorial. I manually added the header file and compiled it:
insert image description here

Click "Translate", there is a warning that no blank line is added at the end:
insert image description here

The location is the underlying file and cannot be modified, so it is ignored here:
insert image description here

(10)Build

Then click "Bulid"
insert image description here

insert image description here

5. Burning

(1) LINKER selection

You can start programming without any errors or warnings. Since I am trying out the PWLINK of Innovation Workshop and adopt the DAP method, I need to modify the burner. You can choose according to your own burner:
insert image description here

In addition, I hope that the program will run directly after downloading, avoiding manual reset, so the following settings are made:
insert image description here

(2) Connect the programmer and the development board

The wiring is as follows:
insert image description here

6. Phenomena

If the burning is successful, you can see that the indicator light starts to flash:
insert image description here

Then everyone can happily start playing with this board.

Guess you like

Origin blog.csdn.net/weixin_43351158/article/details/131709728