本帖最后由 eltonchang2001 于 2022-11-9 11:38 编辑
先从这里下载资料【HT32 Cortex-M 系列懒人包 (整合包)】:https://bbs.21ic.com/icview-3205412-1-1.html找到例程文件夹的example\GPIO\InputOutput
双击_CreateProject.bat创建响应工程
完成后打开工程,修改主函数,实现两个板载LED的闪烁效果:
int main(void)
{
CKCU_Configuration(); /* System Related configuration */
/* Configure WAKEUP, KEY1 pins as the input function */
GPIO_IN_Configuration();
/* Configure LED1, LED2 pins as output function */
GPIO_OUT_Configuration();
/* Infinite loop to read data from input pin and then output to LED */
while (1)
{
//GPIO_MainRoutine();
uint32_t count = 5000000;
static uint32_t TmpStatus = 0;
while (count--) __NOP();
GPIO_WriteOutBits(HTCFG_LED1, HTCFG_OUTPUT_LED1_GPIO_PIN, TmpStatus);
TmpStatus ^= 1;
GPIO_WriteOutBits(HTCFG_LED2, HTCFG_OUTPUT_LED2_GPIO_PIN, TmpStatus);
}
}
如图所示:
|