这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 活动中心 » 板卡试用 » 跳动的心之一——小白的尝试

共5条 1/1 1 跳转至

跳动的心之一——小白的尝试

高工
2019-01-01 17:06:06     打赏

收到板子后,就一直在研究,就想等着做出来后再一并写。中间出了不少问题,但终是把跳动的心做出来了。

下面就开启第一篇吧。

收到后第一件事,当然就是开箱测评了。首先开箱看板子,挺精美的。

通上电后。

在开始正式编写跳动的心的程序前,我先通过例程来熟悉板子端口和STM32CubeMX的使用。虽然以前玩过51系列的单片机,但stm32还是头一次玩。STM32CubeMX这软件以前没接触过,但有着教学视频里小哥哥的讲解,稍微会用了,具体操作我这里就不再赘述了。

我在论坛上翻到了让LD2闪烁的例程,稍微修改了一下,程序部分我这里用的是keil5,直接上例程的程序。

#include "main.h"


#include "stm32f4xx_fsmc.h"


/* Private typedef -----------------------------------------------------------*/

/* Private define ------------------------------------------------------------*/

/* Private macro -------------------------------------------------------------*/

/* Private variables ---------------------------------------------------------*/

RCC_ClocksTypeDef RCC_Clocks;

int main(void)

{

  /*!< At this stage the microcontroller clock setting is already configured, 

       this is done through SystemInit() function which is called from startup

       files before to branch to application main.

       To reconfigure the default setting of SystemInit() function, 

       refer to system_stm32f4xx.c file */


  /* SysTick end of count event each 10ms */

  RCC_GetClocksFreq(&RCC_Clocks);

  SysTick_Config(RCC_Clocks.HCLK_Frequency / 1000);// 

  GPIO_Configuration();


  /* Infinite loop */

  while (1)

  {

GPIO_SetBits(GPIOA,GPIO_Pin_5);

Delay(500);

GPIO_ResetBits(GPIOA,GPIO_Pin_5);

Delay(500);

  }

}




#ifdef  USE_FULL_ASSERT


/**

  * @brief  Reports the name of the source file and the source line number

  *         where the assert_param error has occurred.

  * @param  file: pointer to the source file name

  * @param  line: assert_param error line source number

  * @retval None

  */

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

例程很简单,也就是实现LD2的闪烁,周期大概为1s。定时采用stm32f410板子内部的定时器,直接下载进去就行。

不过有一点我一开始忽略了的就是keil5在加载程序前需要下载相应的PACK资源,我就一开始没有下载,直接打开,而我的keil5破解好像有点问题,它也没提示我需要下载PACK资源,所以我就连灯都没法让他按照我的想法来亮,后来在网上搜索半天才发觉这个问题,小白表示有点难受。

image.png

image.png

找到相应的PACK后下载下来。

对了,我下载中还遇到过下载不了的问题,经过搜索后,才发觉是ST-Link没设置好。然后便开始了设置。

image.png

image.png

image.png

设置好后运行该程序,就得到了LD2一闪一灭的效果,如图。

QQ图片20190101164310.gif

小白的心,从闪烁的LD2开始

附加这个简单的程序,仅供娱乐,哈哈。

STM32F4xx_StdPeriph_Templates.zip




关键词: 跳的的心     尝试    

菜鸟
2019-01-01 21:27:49     打赏
2楼

上图视频是怎么上传的?我怎么上传不了。


管理员
2019-01-02 10:40:19     打赏
3楼

谢谢楼主分享


院士
2019-01-02 19:42:58     打赏
4楼

大家尽量还是要使用“插入代码”这个帖子编辑功能。



高工
2019-01-03 10:09:19     打赏
5楼

插入代码功能了解一下,这看着好累眼睛


共5条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]