关于STM32F030的具体模板,共开发者参考
单片机源程序如下:
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- /*
- STM32F030C8T6模板
- 时钟都在system_stm32f0xxx.里设定。用那个开那个,输出都是48MHZ,最大频率,可以在里面改变大小频率
- #define PLL_SOURCE_HSI // HSI (~8MHz) used to clock the PLL, and the PLL is used as system clock source(~ 8MHz)
- //#define PLL_SOURCE_HSE // HSE (8MHz) used to clock the PLL, and the PLL is used as system clock source
- //#define PLL_SOURCE_HSE_BYPASS // HSE bypassed with an external clock (8MHz, coming from ST-Link) used to clock
-
- 使用内部时钟 48MHZ
- */
- #include "stm32f0xx.h"
- #include "delay.h"
- void LedInit(void)
- {
- GPIO_InitTypeDef GPIO_InitStructure;
- RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA,ENABLE); //GPIOF时钟打开
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; //模式:输出
- GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; //输入类型:上拉/下拉/无
- GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; //输出类型:推挽输出
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //输出速率
- GPIO_Init(GPIOA,&GPIO_InitStructure);
- }
- int main(void)
- {
- delay_init();///定时器初始化,
- LedInit();///LED灯初始代,
-
- while (1)
- {
- GPIO_ResetBits(GPIOA,GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2);
- delay_ms(200); //延时
- GPIO_SetBits(GPIOA,GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2);
- delay_ms(200);
- }
- }
复制代码
所有资料51hei提供下载:
工程模板-F030.zip
(297.96 KB, 下载次数: 222)
|