[ACM32G103RCT6 development board] Unboxing + GPIO peripheral resource verification based on HAL library
[Copy link]
This post was last edited by Misaka10032 on 2023-12-26 23:56
Background
Hello, everyone!
I am a non-professional electronics enthusiast, and I am honored to have applied for the ACM32G103RCT6 development board from Shanghai Hangxin some time ago. After a long 20-day express delivery, I finally got the development board today. Today I will simply unpack the development board and verify the GPIO peripheral resources based on the HAL library. The project file used in this project is the Project_Template project template file provided by Hangxin.
Unboxing
The first thing that comes into view is the front view: (The development board is placed in a plastic box, which is divided into three layers. The bottom layer is a plastic foam, which is used to fix the development board and protect it. The upper layer is the company information business card)
Front view of the development board: This development board is very considerate and has two USB ports on board. If you have installed the driver, you can directly use a C port data cable to download the program. The development board leads out all GPIOs. Not only are they fully led out on the front, but there are also PIN pins on the back, which can be used very conveniently with an expansion board. There are also multiple jumper caps on the front board, which can easily switch between different functions. In addition to a red reset button, there is also a user-defined function button, which is very convenient for users to trigger IO input.
Back of the development board: The workmanship of this development board is very good. I have some other development boards whose PCB thickness is only half of this board.
HAL-based GPIO peripheral resource verification:
Next, I will use the HAL (hardware abstraction library) library officially provided by Hangxin to make the onboard UserLED flash.
Prepare the following materials (KEIL ARM has been installed by default and support for ACM32G103RCT6 has been integrated):
G103 development board resource package_Hangxin.rar (Development board resource package officially provided by Hangxin)
step:
1- Unzip the downloaded G103 development board resource package
2- Step by step enter G103 development board resource package >> development tools >> SDK driver library
3- Unzip ACM32G103_HAL_SDK_V1.1.2.zip
4- Open the unzipped ACM32G103_HAL_SDK
5- Copy the Projects_Templates folder and rename it to whatever you want.
6- Open the MDK-ARM in the copied folder (do not modify the Projects_Templates provided by Hangxin ) and open the current Project
7- If you open it normally, the project structure will be as shown below
After compiling and burning the official template file, the onboard UserLED will flash. I did not use the official BLINK Demo here (the actual effect is the same). If you just want to make the LED flash, you can directly compile and burn the official code. The effect is as follows:
868802ddd35d59e18575aa506bc73abd
principle
So how is this implemented? We need to start with the schematic diagram.
Open the development tools provided by Hangxin >> Development Board >> ACM32G103RCT6_CORE_V1.0.pdf . According to the schematic diagram, the USER LED is connected to port 60 , which is PB3.
So where is PB3 ? Then you need to check the technical documents in the data package >> Hangxin ACM32G103_User Manual_V1.2.PDF ( Page30)
According to the above system architecture diagram, we know that GPIO peripherals are mounted on APB Bridg2 . If we want to use GPIOF , we only need to call the corresponding HAL function to initialize the GPIOF clock after the system clock is initialized.
Similarly, when using other peripheral resources or GPIO, you can refer to the system architecture diagram.
I believe that after reading this, everyone already knows how to write the code. I will post the code I wrote here for your reference and correction:
#include "hal.h"
#include "acm32g103_coreboard.h"
int main(void)
{
uint32_t count=0;
//初始化HAL
HAL_Init();
//初始化系统时钟
SystemClock_Config();
//初始化串口输出
BSP_UART_Init();
GPIO_InitTypeDef GPIO_InitStruct;
// 开启GPIOF时钟
__HAL_RCC_GPIOF_CLK_ENABLE();
//初始化IO PIN
GPIO_InitStruct.Pin = GPIO_PIN_3;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
//设置驱动能力,驱动的电流大小,我这里没有高精密的仪器,无法测量
GPIO_InitStruct.Drive = GPIO_DRIVE_LEVEL3;
//没有找到详细的功能定义 GPIOEx_function_selection
GPIO_InitStruct.Alternate = GPIO_FUNCTION_0;
//使用HAL初始化GPIO
HAL_GPIO_Init(BSP_LED_GPIO, &GPIO_InitStruct);
//闪烁并且Count ++
while(1)
{
HAL_GPIO_WritePin(BSP_LED_GPIO, GPIO_PIN_3, GPIO_PIN_RESET);
HAL_Delay(500);
HAL_GPIO_WritePin(BSP_LED_GPIO, GPIO_PIN_3, GPIO_PIN_SET);
HAL_Delay(500);
printfS("%d\r\n",count++);
};
}
Replenish:
The HAL functions provided by Hangxin are very complete, and many complex operations are abstracted. Users can easily switch from operating registers to learning library functions. Users can use macro definitions in acm32g103_hal_conf.h under the project directory Example/User to determine which HAL library you need to use. In addition, Hangxin also provides Examples of all peripherals, and users can directly copy those Examples as template startup files for corresponding peripherals.
Conclusion :
Thanks again to Hangxin for providing the opportunity to use the development board for evaluation. Please correct any errors in the above code! (I have provided all the codes including the SDK here to prevent you from not finding the library file after downloading. If you use it, please unzip it and open the Template folder in the unzipped file)
|