这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » DIY与开源设计 » 电子DIY » (按键控制流水灯流速+6Runmode)奋斗STM32 ARM DIY进程帖

共17条 2/2 1 2 跳转至
菜鸟
2012-04-18 14:44:29     打赏
11楼
好像有款开发板就叫“奋斗”,莫非····

助工
2012-04-18 20:43:36     打赏
12楼

#include "led.h"
#include "delay.h"
#include "sys.h"
#include "usart.h"
#include "timer.h"
#include "chao.h"
u16 S;
void  StartModule()           
{
   TX=1;                 
   delay_us(15);
   TX=0;
   delay_us(300);
}

void Count()

    S=(TIM3->CNT*340/2000);
 printf("\n测得的距离:%d毫米\n\n",S);
 LED1=!LED1;

 int main(void)
 {
    SystemInit();
 delay_init(72);      //延时初始化
 NVIC_Configuration();
 uart_init(9600);   //串口初始化
 chao_init();
  LED_Init();     //LED端口初始化
 Timerx_Init(60000,71);//10Khz的计数频率,计数到5000为500ms
    while(1)
 {
  printf("\nEEPW ARM DIY 奋斗STM32");
  printf("\n超声波模块测距串口显示\n\n");
  StartModule();
  LED4=!LED4;
  while(RX==0);  //当RX为零时等待
  TIM3->CNT=0;
  TIM_Cmd(TIM3, ENABLE);    //使能定时器3       //开启计数
  while(RX==1);   //当RX为1计数并等待    
  TIM_Cmd(TIM3, DISABLE);    //关闭定时器3
     Count();   //计算
  delay_ms(200);
 }
 }

待会上传视频。。


工程师
2012-04-19 00:19:39     打赏
13楼
学习下楼主的pwm代码~

高工
2012-04-19 22:45:27     打赏
14楼
恭喜~贺喜~

工程师
2012-04-19 23:17:31     打赏
15楼
无图无真相,上传视频图片吧

助工
2012-04-20 19:43:40     打赏
16楼

void KeyDispose(u8 KEY)
{
  if(KEY&0x01)
  {
    LedIndex=0;
 LedDirection=1;
 RunMode=(RunMode+1)%6; 
  }
  if(KEY&0x02)
  {
    if(SystemSpeedIndex<28)
 {
   ++SystemSpeedIndex;
   SetSpeed(SystemSpeedIndex);
 }
  }
   if(KEY&0x04)
  {
    if(SystemSpeedIndex>0)
 {
   --SystemSpeedIndex;
   SetSpeed(SystemSpeedIndex);
 }
  }
}
void TIM3_IRQHandler(void)   //TIM3中断
{
 if (TIM_GetITStatus(TIM3, TIM_IT_Update) != RESET) //检查指定的TIM中断发生与否:TIM 中断源
  {
    TIM_ClearITPendingBit(TIM3, TIM_IT_Update  );  //清除TIMx的中断待处理位:TIM 中断源
       if(++TimerCount>=SystemSpeed)
    {
      TimerCount=0;
   TimerEventRun();
    }
  }
}
 int main(void)
 {
 u8 KEY; 
  SystemInit();  //系统时钟设置
 delay_init(72);      //延时初始化
 NVIC_Configuration();//设置NVIC中断分组2:2位抢占优先级,2位响应优先级
  LED_Init(); //初始化与LED连接的硬件接口
 Init_CPU();
 Timerx_Init(13000,71);
 KEY_Init(); //初始化与按键连接的硬件接口
 while(1)
 {
   KEY=KEY_Scan();
   if(KEY!=0x00)
   {
     KeyDispose(KEY);
   }
 }

 }


助工
2012-04-29 01:13:38     打赏
17楼
最近忙着FPGA的设计。。不能更新了。。版主,很抱歉

共17条 2/2 1 2 跳转至

回复

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