资讯详情

STM32基于3.5库的LED灯2

3.5的库在这里:http://www.51hei.com/mcu/2765.html #include "stm32f10x.h" /*********************************************************************** ************************************************************************/ GPIO_InitTypeDef GPIO_InitStructure; /*********************************************************************** ************************************************************************/ void delay(vu32 nCount) { for(; nCount != 0; nCount--); } /*********************************************************************** ************************************************************************/ main() { /* GPIOD Periph clock enable */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE); /* Configure PD.2 in output pushpull mode */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(GPIOD, &GPIO_InitStructure);

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); /* Configure PA.8 in output pushpull mode */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(GPIOA, &GPIO_InitStructure);

while(1) { GPIO_ResetBits(GPIOD,GPIO_Pin_2); //设置所选定的端口的一个或多个所选定的位为低 GPIO_WriteBit(GPIOA,GPIO_Pin_8,Bit_SET); //置位或清除所选定的特定位 delay(5000000); GPIO_SetBits(GPIOD,GPIO_Pin_2); //设置所选定的端口的一个或多个所选定的位为高 GPIO_WriteBit(GPIOA,GPIO_Pin_8,Bit_RESET); //置位或清除所选定的特定位 delay(5000000); } }

/*PD.2和PA.8端口接LED灯,循环亮灭********************************************* *****************************************************************************/

-电子元器件采购网(www.ruidan.com)是本土元器件目录分销商,采用“小批量、现货、样品”销售模式,致力于满足客户多型号、高质量、快速交付的采购需求。 自建高效智能仓储,拥有自营库存超过50,000种,提供一站式正品现货采购、个性化解决方案、选型替代等多元化服务。
锐单商城拥有海量元器件数据手册IC替代型号,打造 电子元器件IC百科大全!

锐单商城 - 一站式电子元器件采购平台