STM32-5-跑马灯

lemon Lv5

1.代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "stm32f10x.h"

uint16_t temp, i, j;

void Delay(unsigned int count)
{
unsigned int i;
for(; count != 0; count--)
{
i = 5000;
while(i--);
}
}

void main(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);

GPIO_InitStructure.GPIO_Pin = 0x03FF;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
while(1)
{
GPIO_SetBits(GPIOB, 0x0FFFF);
temp = 0x0001;
for(i=0;i<10;i++)
{
GPIO_ResetBits(GPIOB, temp);
Delay(100);
temp =( temp<<1)+1;
}
temp = 0x0FE00;
for(j=0;j<10;j++)
{
GPIO_SetBits(GPIOB, temp);
Delay(100);
temp = (temp>>1)+ 0x8000;
}
}
}

2.模拟图

a


代码下载链接(123云盘):https://www.123684.com/s/wFuijv-i8Zgh

  • 标题: STM32-5-跑马灯
  • 作者: lemon
  • 创建于 : 2025-07-22 22:41:04
  • 更新于 : 2025-07-23 00:13:21
  • 链接: https://lemon2003.github.io/post/20250722224104.html
  • 版权声明: 本文章采用 CC BY-NC-SA 4.0 进行许可。
评论
目录
STM32-5-跑马灯