这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 综合技术 » 基础知识 » 51 51编译的问题,高手请进

共2条 1/1 1 跳转至

51 51编译的问题,高手请进

院士
2006-09-17 18:14:16     打赏
51 51编译的问题,高手请进



关键词: 编译     问题     高手     请进    

院士
2006-12-22 22:43:00     打赏
2楼
问 用的是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;
            }
            
        }

    }
}    

共2条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]