共2条
1/1 1 跳转至页
问
用的是keil V3的,在编译程序时不知何故总有一些语句会被跳过去。请各位高手指点一
下 答 1: 真的跳过去了吗?你再好好想想 答 2: 单步运行跳过 答 3: 可能是编译软件的问题.我是个初学者,请问我这程序问题出在哪里?它不会中断.
#include<reg2051.h>
#include<intrins.h>
#define uint unsigned int
#define uchar unsigned char
#define count 4
uchar buffer[count];
uchar number;
sbit clk=P3^3;
sbit str=P3^4;
sbit dat=P3^5;
void delay(uint k)
{
uint i,j;
for (i=0;i<10;i++)
for (j=k;j>0;j--);
}
void send()
{
uchar i;
for(i=0;i<count;i++)
{
SCON=0x80;
PCON=0x80;
SBUF=buffer[i];
while(1)
{
if(TI)
{
TI=0;
break;
}
}
}
}
void s4094 (uchar k)
{
uchar i;
str=0;
for(i=0;i<8;i++)
{
clk=0;
if(_crol_(k,i)&0x80)
dat=1;
else dat=0;
clk=1;
}
str=1;
}
void display()
{
P1=buffer[1];
buffer[2]&=0x84;
P3=buffer[2];
s4094(buffer[3]);
}
void sdisplay()
{
uchar i;
for(i=0;i<0xff;i++)
{
buffer[1]=0x49;
buffer[2]=0x47;
buffer[3]=0x24;
display();
delay(i);
buffer[1]=0x92;
buffer[2]=0x43;
buffer[3]=0x49;
display();
delay(0xff-i);
}
for(i=0;i<0xff;i++)
{
buffer[1]=0x24;
buffer[2]=0xc3;
buffer[3]=0x92;
display();
delay(i);
buffer[1]=0x49;
buffer[2]=0x47;
buffer[3]=0x24;
display();
delay(0xff-i);
}
for(i=0;i<0xff;i++)
{
buffer[1]=0x92;
buffer[2]=0x43;
buffer[3]=0x49;
display();
delay(i);
buffer[1]=0x24;
buffer[2]=0xc3;
buffer[3]=0x92;
display();
delay(0xff-i);
}
buffer[1]=0x92;
buffer[2]=0x43;
buffer[3]=0x49;
display();
}
void receive()interrupt 4 using 3
{
buffer[number]=SBUF;
number++;
RI=0;
}
void init()
{
buffer[1]=0xff;
buffer[2]=0xff;
buffer[3]=0xff;
display();
number=0;
SCON=0x90;
PCON=0x80;
delay(1000);
}
void main()
{
init();
while(1)
{
EA=1;
ES=1;
REN=1;
if(number>=3)
{
ES=0;
switch(buffer[0])
{
case 0x00:
send();
display();
number=0;
break;
case 0xff:
send();
sdisplay();
number=0;
break;
case 0x01:
display();
number=0;
break;
default:buffer[0]--;
send();
number=0;
break;
}
}
}
}
下 答 1: 真的跳过去了吗?你再好好想想 答 2: 单步运行跳过 答 3: 可能是编译软件的问题.我是个初学者,请问我这程序问题出在哪里?它不会中断.
#include<reg2051.h>
#include<intrins.h>
#define uint unsigned int
#define uchar unsigned char
#define count 4
uchar buffer[count];
uchar number;
sbit clk=P3^3;
sbit str=P3^4;
sbit dat=P3^5;
void delay(uint k)
{
uint i,j;
for (i=0;i<10;i++)
for (j=k;j>0;j--);
}
void send()
{
uchar i;
for(i=0;i<count;i++)
{
SCON=0x80;
PCON=0x80;
SBUF=buffer[i];
while(1)
{
if(TI)
{
TI=0;
break;
}
}
}
}
void s4094 (uchar k)
{
uchar i;
str=0;
for(i=0;i<8;i++)
{
clk=0;
if(_crol_(k,i)&0x80)
dat=1;
else dat=0;
clk=1;
}
str=1;
}
void display()
{
P1=buffer[1];
buffer[2]&=0x84;
P3=buffer[2];
s4094(buffer[3]);
}
void sdisplay()
{
uchar i;
for(i=0;i<0xff;i++)
{
buffer[1]=0x49;
buffer[2]=0x47;
buffer[3]=0x24;
display();
delay(i);
buffer[1]=0x92;
buffer[2]=0x43;
buffer[3]=0x49;
display();
delay(0xff-i);
}
for(i=0;i<0xff;i++)
{
buffer[1]=0x24;
buffer[2]=0xc3;
buffer[3]=0x92;
display();
delay(i);
buffer[1]=0x49;
buffer[2]=0x47;
buffer[3]=0x24;
display();
delay(0xff-i);
}
for(i=0;i<0xff;i++)
{
buffer[1]=0x92;
buffer[2]=0x43;
buffer[3]=0x49;
display();
delay(i);
buffer[1]=0x24;
buffer[2]=0xc3;
buffer[3]=0x92;
display();
delay(0xff-i);
}
buffer[1]=0x92;
buffer[2]=0x43;
buffer[3]=0x49;
display();
}
void receive()interrupt 4 using 3
{
buffer[number]=SBUF;
number++;
RI=0;
}
void init()
{
buffer[1]=0xff;
buffer[2]=0xff;
buffer[3]=0xff;
display();
number=0;
SCON=0x90;
PCON=0x80;
delay(1000);
}
void main()
{
init();
while(1)
{
EA=1;
ES=1;
REN=1;
if(number>=3)
{
ES=0;
switch(buffer[0])
{
case 0x00:
send();
display();
number=0;
break;
case 0xff:
send();
sdisplay();
number=0;
break;
case 0x01:
display();
number=0;
break;
default:buffer[0]--;
send();
number=0;
break;
}
}
}
}
共2条
1/1 1 跳转至页
回复
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |