[STM32G0] STM32CubeMX 主程序

[复制链接]
542|0
 楼主| 4c1l 发表于 2024-11-21 01:22 | 显示全部楼层 |阅读模式
主程序
在主程序中,我们只需要初始化 HAL 库、启动定时器和 GPIO,并进入主循环即可。定时器中断将周期性地触发,改变 LED 状态。

main.c 示例代码:
c
复制代码
#include "stm32f0xx_hal.h"

int main(void)
{
    /* Initialize HAL Library */
    HAL_Init();

    /* Configure the system clock */
    SystemClock_Config();

    /* Initialize GPIO for LED */
    MX_GPIO_Init();

    /* Initialize TIM3 for interrupt */
    MX_TIM3_Init();

    /* Start the timer interrupt */
    HAL_TIM_Base_Start_IT(&htim3);

    /* Main loop */
    while (1)
    {
        /* The LED blinking is handled in the interrupt service routine */
    }
}

您需要登录后才可以回帖 登录 | 注册

本版积分规则

65

主题

703

帖子

2

粉丝
快速回复 在线客服 返回列表 返回顶部