你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

查看: 11022|回复: 20

请问怎样用STM32做一个流水灯实验程序怎么写?谢谢!【悬赏问答】

[复制链接]

1

主题

24

回帖

0

蝴蝶豆

新手上路

最后登录
1970-1-1
发表于 2012-8-6 21:06:09 | 显示全部楼层 |阅读模式
用stm32的pc0-pc3连接四个led灯,让这四个led灯成流水形式亮,之后在pa9接一个中断,只要按下按键pa9就会产生中断并且所有的灯全部熄灭,经过四秒之后有的灯恢复流水灯模式,请问这样的程序怎么写?怎么做呢?谢谢大家!
回复

使用道具 举报

2

主题

240

回帖

0

蝴蝶豆

中级会员

最后登录
2020-8-11
发表于 2012-8-6 22:21:11 | 显示全部楼层

RE:请问怎样用STM32做一个流水灯实验程序怎么写?谢谢!

不知道楼主会51不,会51就一定能写出来,如果不会那就要另说了,
看来楼主的变通能力不强呀...
回复 支持 反对

使用道具 举报

1

主题

24

回帖

0

蝴蝶豆

新手上路

最后登录
1970-1-1
 楼主| 发表于 2012-8-6 23:42:27 | 显示全部楼层

回复:请问怎样用STM32做一个流水灯实验程序怎么写?谢谢!

回复第 2 楼 于2012-08-06 22:21:11发表:
不知道楼主会51不,会51就一定能写出来,如果不会那就要另说了,
看来楼主的变通能力不强呀.
不会呢,麻烦你帮帮忙吧,给我解说下呢,谢谢哈,急用呢。学的不是很好呢,现在要做实验没办法呢,谢谢你哈。
回复 支持 反对

使用道具 举报

7

主题

157

回帖

0

蝴蝶豆

新手上路

最后登录
1970-1-1
发表于 2012-8-8 12:00:23 | 显示全部楼层

回复:请问怎样用STM32做一个流水灯实验程序怎么写?谢谢!【悬赏问答】

主程序循环执行流水灯,按键中断执行灯熄灭延时,楼主要多动手练习
回复 支持 反对

使用道具 举报

5

主题

77

回帖

0

蝴蝶豆

新手上路

最后登录
2018-5-24
发表于 2012-8-8 13:52:13 | 显示全部楼层

回复:请问怎样用STM32做一个流水灯实验程序怎么写?谢谢!【悬赏问答】

找个GPIO的程序认真学习下,相信你应该能搞定
回复 支持 反对

使用道具 举报

2

主题

240

回帖

0

蝴蝶豆

中级会员

最后登录
2020-8-11
发表于 2012-8-8 14:00:59 | 显示全部楼层

RE:请问怎样用STM32做一个流水灯实验程序怎么写?谢谢!【悬赏问答】

同意楼上的方案..
另一种方案是 开一个定时器做计时使用,主循环中查看变量
int  timerled = 0;
int  ledCount = 1;//1代表灯亮 0代表等灭
int  i = 0;
char ledoff = 0;
int  timerkey = 0;

while(1)
{
    if(!ledoff)  
    {
      ledCount = 1;
      for(i = 0;i < 16;i++)
      {
            GPIOA->ODR = ledCount;
            ledCount
回复 支持 反对

使用道具 举报

1

主题

39

回帖

0

蝴蝶豆

新手上路

最后登录
1970-1-1
发表于 2012-8-8 17:35:39 | 显示全部楼层

RE:请问怎样用STM32做一个流水灯实验程序怎么写?谢谢!【悬赏问答】

可以在网上找个流水灯程序学习学习。
回复 支持 反对

使用道具 举报

0

主题

26

回帖

0

蝴蝶豆

新手上路

最后登录
2018-7-5
发表于 2012-8-9 13:28:08 | 显示全部楼层

RE:请问怎样用STM32做一个流水灯实验程序怎么写?谢谢!【悬赏问答】

这是,什么样的一个,程序?
回复 支持 反对

使用道具 举报

24

主题

591

回帖

0

蝴蝶豆

中级会员

最后登录
2020-12-2
发表于 2012-8-9 20:48:20 | 显示全部楼层

RE:请问怎样用STM32做一个流水灯实验程序怎么写?谢谢!【悬赏问答】

#include "stm32f10x.h"
GPIO_InitTypeDef GPIO_InitStructure;

void RCC_Configuration(void);
void Delay(__IO uint32_t nCount);
int main(void)
{
  //uint16_t a;
  /* System Clocks Configuration **********************************************/
  
  RCC_Configuration();   
  
  //
  /* Configure all unused GPIO port pins in Analog Input mode (floating input
     trigger OFF), this will reduce the power consumption and increase the device
     immunity against EMI/EMC *************************************************/
  
/*  RCC_APB2PeriphClockCmd( RCC_APB2Periph_USART1 |RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |
                         RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD |
                         RCC_APB2Periph_GPIOE, ENABLE);
*/
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD,ENABLE);

  
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6|GPIO_Pin_7;                                     //D1  D2
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(GPIOC, &GPIO_InitStructure);                                         
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6|GPIO_Pin_13;                 //D3, D4
  GPIO_Init(GPIOD, &GPIO_InitStructure);
  while (1)
  {
  
  
    GPIO_SetBits(GPIOC, GPIO_Pin_6);// D1亮                  
    Delay(0xAFFFF);
    GPIO_SetBits(GPIOC, GPIO_Pin_7 );        //D2亮         
    GPIO_ResetBits(GPIOC, GPIO_Pin_6);        //D1灭
    Delay(0xAFFFF);
    GPIO_SetBits(GPIOD, GPIO_Pin_13 );        //D3亮         
    GPIO_ResetBits(GPIOC, GPIO_Pin_7);        //D2灭
    Delay(0xAFFFF);
    GPIO_SetBits(GPIOD, GPIO_Pin_6 );        //D4亮         
    GPIO_ResetBits(GPIOD, GPIO_Pin_13);        //D3灭
    Delay(0xAFFFF);
    GPIO_ResetBits(GPIOD, GPIO_Pin_6);        //D4灭
  }
}

void RCC_Configuration(void)
{   
  /* Setup the microcontroller system. Initialize the Embedded Flash Interface,  
     initialize the PLL and update the SystemFrequency variable. */
  SystemInit();
}

void Delay(__IO uint32_t nCount)
{
  for(; nCount != 0; nCount--);
}
#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
回复 支持 反对

使用道具 举报

1

主题

24

回帖

0

蝴蝶豆

新手上路

最后登录
1970-1-1
 楼主| 发表于 2012-8-11 22:56:09 | 显示全部楼层

回复:请问怎样用STM32做一个流水灯实验程序怎么写?谢谢!【悬赏问答】

回复第 4 楼 于2012-08-08 12:00:23发表:
主程序循环执行流水灯,按键中断执行灯熄灭延时,楼主要多动手练习
 

谢谢你哈。我会好好努力的。
回复 支持 反对

使用道具 举报

关于意法半导体
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
招聘信息
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
关注我们
st-img 微信公众号
st-img 手机版