Recently, Hezhou has produced a:
TSSOP20封装、ARM®Cortex®-M0+内核,内置32K Flash+4K RAM、集成多路USART、IIC、SPI等通讯外设,5个16bit定时器以及1路12bit 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】
Unzip the downloaded file and go into the PACK folder:
2. Install PACK
Double-click to open the .pack file for installation:
Click NEXT to complete the installation
3. Create a new Keil project
Open Keil, click "Project" - "New μVison Project"
Then click OK after selecting an appropriate location and name:
Select the Air001 chip in the pop-up window, and click "OK":
In the pop-up window, check "CORE" in "CMSIS" and "Stratup" in "Device", and then click "OK":
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:
(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:
(3) Create a new main.c
First create a main.c file
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:
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:
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:
(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":
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
(6) Create new air001xx_it.c
The same operation, create a new "air001xx_it.c" file:
#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();
}
(7) Add header file path
Next, start to add the path, first click "Options for Target", which is the "magic wand"
Then select the extension button on the right of "C/C++" – "Includes Paths":
Add the following paths, and finally click "OK":
(8) Add macro definition
Add the macro definition "AIR001_DEV" and click "OK"
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]:
I have a small problem when compiling 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:
Click "Translate", there is a warning that no blank line is added at the end:
The location is the underlying file and cannot be modified, so it is ignored here:
(10)Build
Then click "Bulid"
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:
In addition, I hope that the program will run directly after downloading, avoiding manual reset, so the following settings are made:
(2) Connect the programmer and the development board
The wiring is as follows:
6. Phenomena
If the burning is successful, you can see that the indicator light starts to flash:
Then everyone can happily start playing with this board.