• «
  • 1
  • 2
  • »
  • Pages: 1/2     Go
主题 : 这个LED程序,问题在那里呀?刚学ARM(己解决,初学者可以进来学习一下) 复制链接 | 浏览器收藏 | 打印
级别: 侠客
UID: 709
精华: 1
发帖: 88
金钱: 595 两
威望: 131 点
综合积分: 196 分
注册时间: 2008-05-18
最后登录: 2018-02-08
楼主  发表于: 2008-06-21 01:07

 这个LED程序,问题在那里呀?刚学ARM(己解决,初学者可以进来学习一下)

刚学ARM,买了个QQ2440V3,心急想写个程序爽一把,但是没成功,郁闷!请高手帮我看看程序,给我指点一二

用ADS时没有错误,ADS设置也没有问题,编译时没有错误,只有一个警告,大体意思好像是说找不到指向main的指针入口。

程序如下,请大家看看


#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 port_init(void);//端口初始化
void delay(uchar delay_temp);//长延时



int Main()
{
        port_init();  //初始化GPB5到GPB8口为output
       
        for(;;)
            {
            rGPBDAT=(rGPBDAT&0x20F)|0x2F0;
            delay(0xff);
            rGPBDAT=(rGPBDAT&0x20F)|0x370;
            delay(0xff);
            rGPBDAT=(rGPBDAT&0x20F)|0x3a0;
            delay(0xff);
            rGPBDAT=(rGPBDAT&0x20F)|0x3c0;
            delay(0xff);
            }



}
           



void port_init(void)
{
    rGPBCON=(rGPBCON|0X0FFC00)&0XF557FF;//GPB5--GPB8设置为output
    rGPBUP|=0X1E0;//不上拉电阻

}

void delay(uchar delay_temp)//延时子程序
{
    uchar i,j;
    for(i=0;i<delay_temp;i++)
    {
        for(j=0;j<255;j++);
    }
}
[ 此贴被maidilong在2008-06-22 22:17重新编辑 ]
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
1楼  发表于: 2008-06-21 06:55
先不论程序的源代码是否有问题,我倒是很好奇你怎么运行这个程序的
"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: 709
精华: 1
发帖: 88
金钱: 595 两
威望: 131 点
综合积分: 196 分
注册时间: 2008-05-18
最后登录: 2018-02-08
2楼  发表于: 2008-06-21 08:15
嗯~~就是不太懂!刚买的板,当个普通单片机用。用jtag调试没反应
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
3楼  发表于: 2008-06-21 12:38
那你也得初始化CPU吧:)
"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: 709
精华: 1
发帖: 88
金钱: 595 两
威望: 131 点
综合积分: 196 分
注册时间: 2008-05-18
最后登录: 2018-02-08
4楼  发表于: 2008-06-22 22:09
谢谢版请的提醒~~我以为ARM就像51单片机那样,不用初始化内存空间就能用的,所以前天我编的程序一直不能运行,原来ARM要初始化才能用的,现在我的程序能运行了,第一次成功了,哈哈,真爽!总算也明白了点什么!!

我原来的程序没错误,就是没有初始化CPU,现在加上了初始化语句成功的运行了流水灯程序,现在特来感谢版主,他两次给我回贴,精神很可敬!向版主致敬!谢谢~~~


下面是我运行的程序,也希望给后来的初学者有个启示作用!


#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 port_init(void);//端口初始化
void delay(uchar delay_temp);//长延时



int Main()
{
        port_init();  //初始化GPB5到GPB8口为output
       
        for(;;)
          {
            rGPBDAT=(rGPBDAT&0x20F)|0x2F0;
            delay(0xff);
            rGPBDAT=(rGPBDAT&0x20F)|0x370;
            delay(0xff);
            rGPBDAT=(rGPBDAT&0x20F)|0x3a0;
            delay(0xff);
            rGPBDAT=(rGPBDAT&0x20F)|0x3c0;
            delay(0xff);
            }



}
         



void port_init(void)
{
    rGPBCON=(rGPBCON|0X0FFC00)&0XF557FF;//GPB5--GPB8设置为output
    rGPBUP|=0X1E0;//不上拉电阻

}

void delay(uchar delay_temp)//延时子程序
{
    uchar i,j;
    for(i=0;i<delay_temp;i++)
    {
        for(j=0;j<255;j++);
    }
}
描述:LED程序工程文件
附件: my led.rar (83 K) 下载次数:105
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
5楼  发表于: 2008-06-22 23:22
呵呵,大家一起学习交流是应该的,不用客气;
如果想要给初学者一些经验,我觉得你可以告诉大家要从S3C2440上电Reset到操作LED需要经过哪些必要的初始化,这才是我们学ARM真正有价值的地方
"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: 977
精华: 0
发帖: 1
金钱: 10 两
威望: 1 点
综合积分: 2 分
注册时间: 2008-07-02
最后登录: 2008-07-21
6楼  发表于: 2008-07-02 15:00
请问楼主cpu初始化部分是你自己写的吗?
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
7楼  发表于: 2008-07-02 20:03
那部分代码应该是从三星提供的CPU测试程序里直接拿的。在友善之臂提供的光盘上也有提供,名字应该叫2440test吧
"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: 1101
精华: 0
发帖: 1
金钱: 10 两
威望: 1 点
综合积分: 2 分
注册时间: 2008-07-19
最后登录: 2009-10-04
8楼  发表于: 2008-07-19 14:43
很好,很好
学习linux了。
级别: 新手上路
UID: 448
精华: 0
发帖: 37
金钱: 285 两
威望: 65 点
综合积分: 74 分
注册时间: 2008-04-03
最后登录: 2015-05-14
9楼  发表于: 2008-07-21 14:13
版主很负责啊
庆祝淘宝http://gooogleman.taobao.com/淘出一层小洋楼,特此限量促销10个mini2440 开发板
  • «
  • 1
  • 2
  • »
  • Pages: 1/2     Go