导航: 老古网老古论坛XMOS公共讨论区XMOS开源项目区单片机程序设计嵌入式系统广告区域
→c语言程序问题[jola]

 *第18409篇: c语言程序问题

  
楼 主:jola 2004年1月2日13:32
 c语言程序问题
程序如下,
#include  <reg51.h>  
#include  <stdio.h>  
#define uint unsigned int
#define uchar unsigned char
void delay(void);
uchar keyscan();
void main(void)
{
uchar key;
while(1)
{key=keyscan();
delay();}
}
void delay(void)
{uchar i;
for(i=0;i  <200;i++){}
}
uchar keyscan(void)
{
uchar code_h;
uchar code_l;
p1  =0xf0;
if((p1&0xf0)!=0xf0)
{
delay();
if((p1&0xf0)!=0xf0)
  {
    code_h=0xfe;
    while((code_h&p1)!=0xf0)
     {
      p1=code_h;
      if((p1&0xf0)!=0xf0)
      {
        code_l=(p1&0xf0|0x0f);
        return((~code_h)+(~code_l));
       }
        else
             code_h=(code_h  <  <1)|0x01;
        }
       }
     }
return(0);
}
编译后的信息是:
Build target 'Target 1'
compiling prog.c...
PROG.C(22): error C141: syntax error near '='
PROG.C(23): error C190: '&': not an lvalue
PROG.C(26): error C190: '&': not an lvalue
PROG.C(29): error C141: syntax error near ')'
PROG.C(29): error C141: syntax error near '!='
PROG.C(29): error C141: syntax error near ')'
PROG.C(32): error C190: '&': not an lvalue
PROG.C(34): error C190: '&': not an lvalue
Target not created
为什么会这样呢?????


  
2楼:guest 2004年1月2日14:02
 读取p1口最好加个寄存器

temp
读取p1口最好加个寄存器

temp=p1;
if((temp&0xf0)!=0xf0)

  
3楼:rou_wexx 2004年1月5日21:15
 我想这样写的话在多任务环境中对函数的可重
我想这样写的话在多任务环境中对函数的可重入性有很大作用。
  
4楼:jola 2004年1月2日14:11
 ?????
为什么要这样呢?能解释一下吗???那怎么来定义TEMP呢??
谢谢!
  
5楼:jola 2004年1月2日23:40
 再请回复!
再请回复!谢谢!!
  
6楼:guest 2004年1月5日10:37
 你的P1口引用错了,P应该大写的!
你的P1口引用错了,P应该大写的!
  
7楼:feather 2004年1月5日12:39
 一是看大小写,还有就是p1后边不要空格
  
8楼:guest 2004年1月5日16:36
 在用P口时,一定要大写。
在用P口时,一定要大写。
  
9楼:guest 2004年1月6日10:57
 c51里边可以定义小写的

>>>>>>对该主题发表你的看法

本主题贴数9,分页: [第1页]


[上一篇主题]:那位大侠有Pt电阻测量温度的电路图

[下一篇主题]:求助~~~智能化仪器课程设计