Arm Community
Arm Community
  • Site
  • User
  • Site
  • Search
  • User
  • Groups
    • Research Collaboration and Enablement
    • DesignStart
    • Education Hub
    • Innovation
    • Open Source Software and Platforms
  • Forums
    • AI and ML forum
    • Architectures and Processors forum
    • Arm Development Platforms forum
    • Arm Development Studio forum
    • Arm Virtual Hardware forum
    • Automotive forum
    • Compilers and Libraries forum
    • Graphics, Gaming, and VR forum
    • High Performance Computing (HPC) forum
    • Infrastructure Solutions forum
    • Internet of Things (IoT) forum
    • Keil forum
    • Morello Forum
    • Operating Systems forum
    • SoC Design and Simulation forum
    • 中文社区论区
  • Blogs
    • AI and ML blog
    • Announcements
    • Architectures and Processors blog
    • Automotive blog
    • Graphics, Gaming, and VR blog
    • High Performance Computing (HPC) blog
    • Infrastructure Solutions blog
    • Innovation blog
    • Internet of Things (IoT) blog
    • Operating Systems blog
    • Research Articles
    • SoC Design and Simulation blog
    • Tools, Software and IDEs blog
    • 中文社区博客
  • Support
    • Arm Support Services
    • Documentation
    • Downloads
    • Training
    • Arm Approved program
    • Arm Design Reviews
  • Community Help
  • More
  • Cancel
中文社区
中文社区
中文社区博客 STM32F031-Nucleo初体验(寄存器+固件库操作LED)
  • Blogs
  • Forum
  • 视频和文件
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • Jump...
  • Cancel
  • New
中文社区 requires membership for participation - click to join
More blogs in 中文社区
  • ARM中国大学计划博客

  • Arm新闻

  • 中文mbed博客

  • 中文社区博客

  • 恩智浦汽车电子MCU讨论区博客

 

Tags
  • chinese
  • Embedded
  • 嵌入式
  • 中文
Actions
  • RSS
  • More
  • Cancel
Related blog posts
Related forum threads

STM32F031-Nucleo初体验(寄存器+固件库操作LED)

Audier
Audier
December 27, 2015
1 minute read time.

首先感谢ST和ARM中文社区举办这次活动,让我有机会拿到开发板。

这款Nucleo板真心很小,估测了一下大约5*1.85(cm^2)的尺寸。不过麻雀虽小五脏俱全,该有的基本功能都有,只是受限于板子尺寸的问题难以集成其他高级功能。

由于本人接触STM32的时间不长,也是第一次接触到F0的板子,所以拿到板子首先看了一下社友们的帖子,学到了很多,例如CubeMX、在线Mbed编程等。查看了一下社友们的例程多以Cube库变成或者寄存器编程,所以想着自己做一个标准库的LED程序。借助网上的工程模板对LED的程序进行编写、修改后,做了LED的闪烁实验:(本人经验不足如有问题,请社友们多多指正!)

IMG_20151228_114554.jpg

主函数代码:

/* Includes ------------------------------------------------------------------*/

#include "stm32f0xx.h"

void GPIO_InitConfig(void);

void Delay_us(__IO uint32_t nCount);

void Delay_ms(__IO uint32_t nCount);

/******************************************************************************

* Function Name   : main

* Description     : 主程序

* Input           : None

* Output         : None

* Return : None

* Attention : None

******************************************************************************/

int main(void)

{

  GPIO_InitConfig();

  while (1)

  {

  GPIO_WriteBit(GPIOB,GPIO_Pin_3,Bit_SET); //写“1”

  Delay_ms(100);

  GPIO_WriteBit(GPIOB,GPIO_Pin_3,Bit_RESET); //写“0”

  Delay_ms(100);

  //置位对应的GPIO口

  GPIO_SetBits(GPIOB,GPIO_Pin_3);

  Delay_ms(500);

  //复位对应的GPIO口

  GPIO_ResetBits(GPIOB,GPIO_Pin_3);

  Delay_ms(500);

  /*----- 寄存器操作 -----*/

  GPIOB->BSRR = (GPIO_Pin_3);//置位对应GPIO位

  Delay_ms(500);

  GPIOB->BRR = (GPIO_Pin_3);//复位对应GPIO位

  Delay_ms(100);

  }

}

/******************************************************************************

* Function Name   : GPIO_InitConfig

* Description     : GPIO配置

******************************************************************************/

void GPIO_InitConfig(void)

{

  GPIO_InitTypeDef        GPIO_InitStructure;

  /* GPIOC Periph clock enable */

  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);

  /* Configure PC8 and PC9 in output pushpull mode */

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;

  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;

  GPIO_Init(GPIOB, &GPIO_InitStructure);

}

/******************************************************************************

* Function Name   : Delay | Delay_us

* Description     : 延迟程序

* Input           : nCount: 延时长度

******************************************************************************/

void Delay(__IO uint32_t nCount)

{

  /* Decrement nCount value */

  while (nCount != 0)

  {

  nCount--;

  }

}

void Delay_us(__IO uint32_t nCount)

{

  /* 10uS延迟=>10.8uS,100uS延迟=>104uS*/

  while (nCount != 0)

  {

  nCount--;

  Delay(10);

  }

}

void Delay_ms(__IO uint32_t nCount)

{

  /* 10uS延迟=>10.8uS,100uS延迟=>104uS*/

  while (nCount != 0)

  {

  nCount--;

  Delay(11000);

  }

}

#ifdef  USE_FULL_ASSERT

void assert_failed(uint8_t* file, uint32_t line)

{

  /* User can add his own implementation to report the file name and line number,

     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

  /* Infinite loop */

  while (1)

  {

  }

}

#endif

/*******************************************************************************

      END OF FILE

*******************************************************************************/

Anonymous
中文社区博客
  • Arm A-Profile构架2022扩展

    Zenon Xiu (修志龙)
    Zenon Xiu (修志龙)
    原文:Arm A-Profile Architecture Developments 2022 - Architectures and Processors blog - Arm Community blogs - Arm Community  作者:Martin Weidmann翻译:修志龙(Zenon Xiu) 与arm构架授权和生态伙伴一起,arm持续演进其构架,开发新功能以满足现有和新市场的要求…
    • October 17, 2022
  • 深入理解 Arm A-profile的non-maskable interrupt -NMI

    Zenon Xiu (修志龙)
    Zenon Xiu (修志龙)
    原文: https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/a-profile-non-maskable-interrupts  翻译: 修志龙 Zenon Xiu Arm A-profile构架一个长久以来的局限性是:缺乏对non-maskable interrupt (NMI…
    • August 24, 2022
  • Arm A-Profile 构架2021扩展

    Zenon Xiu (修志龙)
    Zenon Xiu (修志龙)
    原文: https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/arm-a-profile-architecture-developments-2021 Martin Weidmann September 8, 2021 翻译注释:Zenon Xiu Arm与arm构架授权公司及生态伙伴一起…
    • August 17, 2022