mqgz 发表于 2009-10-19 17:29:15

proteus仿真arm中的问题

最近根据周立功的深入浅出arm7上学习arm,发现在仿真按键时出现了一个问题,判断按键是否按下时书中介绍是用语句if(IO0PIN&KEY1==0)来进行判断,实际仿真结果不行,后来经过反复修改发现if(IO0PIN&0x100)是可以正常运行,不知道什么原因,请各位大侠赐教,原代码如下
#include "config.h"

#define KEY1(1<<8)
void DelayNS(uint32 dly)
{ uint32 i;

for(;dly>0;dly--)
      for(i=0;i<50000;i++);
}
const uint32 LED_TBL[]={0x00,0xFF,0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,
                                0x01,0x03,0x07,0x0F,0x1F,0x3F,0x7F,0xFF,
                                0xFF,0x7F,0x3F,0x1F,0x0F,0x07,0x03,0x01,
                                0x81,0x42,0x24,0x18,0x18,0x24,0x42,0x81,
                                0x81,0xC3,0xE7,0xFF,0xFF,0xE7,0xC3,0x81};
int main (void)
{
    uint8 i;
    PINSEL0=0x00000000;
    IO0DIR =0x000000FF;
    while(1)
    {
      if(IO0PIN&0x100)   //注意此处IO0PIN&0x100==1或者==0则跑马灯不会亮
      {
      for(i=0;i<42;i++)
      {
      IO0SET=~LED_TBL;
      DelayNS(10);
      IO0CLR=LED_TBL;
      DelayNS(10);
      if(!(IO0PIN&0x100))break;
      }
   }
   }
    return 0;
}
点击此处下载 ourdev_493481.rar(文件大小:135K) (原文件名:key.rar) ,附件已可正常运行

millwood0 发表于 2009-10-19 18:20:04

if (IO0PIN&0x100) is true if IO0PIN's eighth digit is 1;

if ((IO0PIN&KEY1)==0) is true if IO0PIN's eighth digit is 0.

notice the brackets I put around IO0PIN & KEY1.

mqgz 发表于 2009-10-20 09:55:20

First, thank you very much for the answer, but, follow your said it still don't work after add brackets, do not know whether you had download my accessories, modified files in the simulation of operation, in fact, it didn't work!

mqgz 发表于 2009-10-20 15:39:19

按照2楼的if ((IO0PIN&KEY1)==0) 或者if ((IO0PIN&KEY1)==1)这样加了括号也是不行,目前有四十几个人浏览过,但没人能回答,看样子这里高手很少啊,莫非论坛里只有百分之一抑或千分之一的人 才真正有实力?
页: [1]
查看完整版本: proteus仿真arm中的问题