主题 : LED流水灯 复制链接 | 浏览器收藏 | 打印
级别: 新手上路
UID: 20620
精华: 0
发帖: 7
金钱: 35 两
威望: 7 点
贡献值: 0 点
综合积分: 14 分
注册时间: 2010-05-05
最后登录: 2010-05-14
楼主  发表于: 2010-05-13 14:30

 LED流水灯

参考论坛里各位兄弟的资料,写了mimi2440板的led流水灯,贴出来,回报论坛
#include"def.h"
#include"option.h"
#include"2440addr.h"
#include"2440lib.h"
#include"2440slib.h"

#define rGPBCON    (*(volatile unsigned *)0x56000010)    //Port B control
#define rGPBDAT    (*(volatile unsigned *)0x56000014)    //Port B data
#define rGPBUP    (*(volatile unsigned *)0x56000018)    //Pull-up control B

#define uchar unsigned char
#define uint  unsigned int
#define ulong unsigned long

void delay(uchar tt)
{
   ulong i;
   for(;tt>0;tt--)
   {
     for(i=0;i<1000000;i++){}
   }
}


void port_init(void)
{
  rGPBCON = 0x005555f0;
  rGPBDAT=0X0000;
  rGPBDAT=0X00FFFFFF;
  rGPBUP  = 0x001;      //关闭GB0上拉电阻
}


int Main()
{ uint i;
  ulong data;
port_init();

while(1)
{    
    data=0xfdf;
    
for(i=0;i<4;i++)
      {   rGPBDAT=data;
          delay(0x0f);
          data=data<<1;                  
   }
}
}
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
贡献值: 71 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
1楼  发表于: 2010-05-13 14:59
多谢分享
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 新手上路
UID: 5171
精华: 0
发帖: 35
金钱: 250 两
威望: 100 点
贡献值: 0 点
综合积分: 70 分
注册时间: 2009-04-13
最后登录: 2016-03-30
2楼  发表于: 2010-05-25 23:54
多谢哥们  终于过了  但是没找到我的程序为什么不行  郁闷中
好好学习 天天向上
级别: 新手上路
UID: 105551
精华: 0
发帖: 7
金钱: 35 两
威望: 7 点
贡献值: 0 点
综合积分: 14 分
注册时间: 2014-06-27
最后登录: 2014-07-15
3楼  发表于: 2014-07-14 17:15
这个程序能用到MICRO2440板子上吗