日期:2014-05-16  浏览次数:20649 次

uclinux新手急切求助
编写了一个控制LED闪亮的程序test.c,用如下指令编译:
arm-elf-gcc   -Wall   -O2   -Wl,-elf2flt   -g   -o   test   test.c

test.c程序如下:
#include   <stdlib.h>
#include   <stdio.h>

#define   rPCONE   (*(volatile   unsigned   *)0x1d20028)
#define   rPDATE   (*(volatile   unsigned   *)0x1d2002c)
#define   rPUPE   (*(volatile   unsigned   *)0x1d20030)

void   wtDelay(int   time)
{
  int   i;
  for(;time> 0;time--)
  {
    for(i=0;i <100;i++);
  }
}

int   main(void)
{
  int   i=10;
  printf( "LED   test!\nCompiled   by   robosky!\n ");

  rPDATE   =   0xff;
  rPCONE   =   0x500;   //GPE5   and   GPE6   are   output   port!
  rPUPE   =   0xffff;   //Disable   pullup   resister

while(i)
{
  rPDATE   =   0xff;     //LED   OFF
  wtDelay(5000);
  rPDATE   =   0x0;     //LED   ON
  wtDelay(5000);
  i--;
  if(!i)   {
  printf( "Set   i   to   a   new   value(input   0   to   quit): ");
  scanf( "%d ",&i);
  }  
}
return   0;
}

将得到的test下载到开发板,然后在开发板上执行./test   。

结果LED的确闪亮了几次,可在终端上只打印出“LE”就没反应了;而不是期望的输出:
LED   test!
Compiled   by   robosky!
Set   i   to   a   new   value(input   0   to   quit):

这个问题都浪费我一周多时间了,真想哭了...
请各位前辈帮忙分析一下啊,感激涕零!

------解决方案--------------------
加个GDB调试吧
------解决方案--------------------
支持!
高手回答下!
------解决方案--------------------
昏,不懂...有待加强!


那么长的代码,你检查看看有没有些错的地方.
------解决方案--------------------
你加几句代码在第一行可疑的块当中
包括循环里面 看看是不是打印输出了
我觉得你的循环变量i似乎定义和使用的有问题
你最好把I 全部打印出来 看看
上面的什么LED什么的 根本不需要