1. The MCU of Hangshun's HK32F030 is very user-friendly. There is a plug-in package for this MCU in the attachment package below. You can download it and install it in keil.
2. After installing the device library, you can get the HK32F0XX_LibraryV1.0.8 file in the function library and unzip it. There will be a built example project under the templates file.(PS: Everyone should pay attention to the chip model)
3. The chip of my board should be selected as engineer hk32f030_STD. After opening, we only run the main file.
4. Since the first thing to do when lighting up is to initialize the GPIO pin, I will directly enter the code.
void HK_EVAL_LEDInit(void)
{
//PC6 PC7
GPIO_InitTypeDef GPIO_InitStructure;//声明一个结构体
/* 使能GPIO时钟 */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);
/*初始化LED的GPIO*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6|GPIO_Pin_7;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
/*设置GPIO速度为10M*/
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_Level_2;
GPIO_Init(GPIOC, &GPIO_InitStructure);
}
In this way, we will complete the GPIO initialization operation.
5. Write a delay function. The delay function here is the old solution. Also go directly to the code
static __IO uint32_t TimingDelay;
void Delay_ms(__IO uint32_t nTime)
{
TimingDelay = nTime;
while(TimingDelay != 0);
}
void TimingDelay_Decrement(void)
{
if (TimingDelay != 0x00)
{
TimingDelay--;
}
}
6. Next we will write the control function of the LED light.
void HK_EVAL_LED1Off(void)
{
GPIOC->BSRR = GPIO_Pin_6;
}
void HK_EVAL_LED2Off(void)
{
GPIOC->BSRR = GPIO_Pin_7;
}
void HK_EVAL_LED1On(void)
{
GPIOC->BRR = GPIO_Pin_6;
}
void HK_EVAL_LED2On(void)
{
GPIOC->BRR = GPIO_Pin_7;
}
7. After that, let’s create a small main function
int main(void)
{
/* 设置系统时钟为1ms(就是SysTick Timer) */
if (SysTick_Config(SystemCoreClock / 1000))
{
/* 如果没设置成功直接死循环 */
while (1);
}
//初始化IO口
HK_EVAL_LEDInit();
/*开始死循环*/
while(1)
{
Delay_ms(250);
HK_EVAL_LED1On();
HK_EVAL_LED2Off();
Delay_ms(250);
HK_EVAL_LED1Off();
HK_EVAL_LED2On();
}
}
8. Come and start compiling! ! ! ! ! ! !
I hope you can also see this situation above
9. Come and download!
I gave Chuangxin Workshop a PowerWriter here, so I used it to study it. Now I’ll talk about the process.
The example of the wiring of the downloader to the chip is given in the core creation workshop as shown in the figure
My wiring is:
First, go to the official website of Innovation Workshop to download the software and give the address: https://www.icworkshop.com/user/btDetails/pw/7
After the installation is complete, open the software as shown in the figure,
click to select the chip
, and then click Apply
to connect. Come down and add our hex file.
Adding the file here is done. Next we start burning.
ps: If any young lady likes me, she is also welcome
All reference designs on this site are sourced from major semiconductor manufacturers or collected online for learning and research. The copyright belongs to the semiconductor manufacturer or the original author. If you believe that the reference design of this site infringes upon your relevant rights and interests, please send us a rights notice. As a neutral platform service provider, we will take measures to delete the relevant content in accordance with relevant laws after receiving the relevant notice from the rights holder. Please send relevant notifications to email: bbs_service@eeworld.com.cn.
It is your responsibility to test the circuit yourself and determine its suitability for you. EEWorld will not be liable for direct, indirect, special, incidental, consequential or punitive damages arising from any cause or anything connected to any reference design used.
Supported by EEWorld Datasheet