音影先锋亚洲天堂网|电影世界尽头的爱完整版播放|国产 熟女 91|高清无码免费观看欧美日韩|韩国一区二区三区黄色录像|美女亚洲加勒比在线|亚洲综合网 开心五月|7x成人在线入口|成人网站免费日韩毛片区|国产黄片?一级?二级?三级

登錄 免費(fèi)注冊 首頁 | 行業(yè)黑名單 | 幫助
維庫電子市場網(wǎng)
技術(shù)交流 | 電路欣賞 | 工控天地 | 數(shù)字廣電 | 通信技術(shù) | 電源技術(shù) | 測控之家 | EMC技術(shù) | ARM技術(shù) | EDA技術(shù) | PCB技術(shù) | 嵌入式系統(tǒng)
驅(qū)動編程 | 集成電路 | 器件替換 | 模擬技術(shù) | 新手園地 | 單 片 機(jī) | DSP技術(shù) | MCU技術(shù) | IC 設(shè)計(jì) | IC 產(chǎn)業(yè) | CAN-bus/DeviceNe

請教AT93c46與AT89C52的通訊程序

作者:yujun223 欄目:通信技術(shù)
請教93C46.html">AT93C46AT89C52的通訊程序
朋友們幫個忙,幫我看看這段程序
93C46.html">AT93C46AT89C52的通訊程序
93C46的ORG接地,采用八位方式

#include <reg52.h>
sbit CS=P3^4;
sbit SK=P3^3;
sbit DI=P3^1;
sbit DO=P3^0;
void Ewen(void) {
    unsigned CHAR TEMP,InData;
    CS=0;    
    SK=0;
    CS=1;
    InData=0x98;    // 10011XXXX
    for(TEMP=9;TEMP!=0;TEMP--) {    // 9
        DI=InData&0x80;
        SK=1;    SK=0;
        InData<<=1;
    }
    CS=0;
}
// Disables all PROGRAMMING instructions.
void Ewds(void) {
    unsigned CHAR TEMP,InData;
    CS=0;
    SK=0;
    CS=1;
    InData=0x80;    // 10000XXXX
    for(TEMP=9;TEMP!=0;TEMP--) {    // 9
        DI=InData&0x80;
        SK=1;    SK=0;
        InData<<=1;
    }
    CS=0;
}
// Reads data stored in MEMORY, at specified address.
unsigned int Read(unsigned CHAR address) {
    unsigned CHAR TEMP;
    unsigned CHAR result;
    Ewen();
    SK=0;    
    DI=1;    // 110 A6-A0
    CS=0;    
    CS=1;
    SK=1;    
    SK=0;
    DI=1;
    SK=1;    
    SK=0;
            // 1
    address=address&0x7f;
    for(TEMP=8;TEMP!=0;TEMP--) {    // 8
        DI=address&0x80;
        SK=1;    
        SK=0;
        address<<=1;
    }
    DO=1;
    for(TEMP=8;TEMP!=0;TEMP--) {    // 八位數(shù)據(jù)
        SK=1;
        result=(result<<1)|DO;
        SK=0;
    }
    CS=0;
    Ewds();
    return(result);
}
// Writes MEMORY location An - A0.
void Write(unsigned CHAR address,unsigned CHAR InData)
{
    unsigned CHAR TEMP;
    Ewen();
    SK=0;    
    DI=1;    // 101 A6-A0
    CS=0;    
    CS=1;
    SK=1;    
    SK=0;    
    DI=0;
    SK=1;    
    SK=0;        // 1
    address=address|0x80;
    for(TEMP=8;TEMP!=0;TEMP--) {    // 8
        DI=address&0x80;
        SK=1;    
        SK=0;
        address<<=1;

    }
    for(TEMP=8;TEMP!=0;TEMP--) {    // 8位數(shù)據(jù)
        DI=InData&0x80;
        SK=1;    
        SK=0;
        InData<<=1;
    }
    CS=0;    DO=1;
    CS=1;    SK=1;
    while(DO==0) {            // busy TEST
        SK=0;    SK=1;
    }
    SK=0;    CS=0;
    Ewds();
}

void delay(unsigned int x)
{
  unsigned CHAR j;
  while (x-->0)
  {
    for (j=0;j<125;j++)
       {;}
  }
}


main()
{
  unsigned CHAR trans_data[16]={0xc0,0xf9,0xa4,0xb0,0x99,
  0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc5,0xa1,0x86,0x8e};//bcd碼0-F,共陽極
  unsigned CHAR maddress
  unsigned CHAR i=0;
  maddress=0x00;
  for(;i<16;i++)
  {
  Write(maddress++,trans_data[i]);
  }
  while(1)
  {     
        maddress=0;
        while(maddress<0x10)
       {
           P1=Read(maddress);
          delay(300);
          P1=0xFF;
          delay(300);
          maddress++;
        }
          
  }
}
  
結(jié)果只出來6。為什么??




參與討論
昵稱:
討論內(nèi)容:
 
 
相關(guān)帖子
電話線上的信號
請問手機(jī)中ESD器件是如何選擇,主要看那幾個參數(shù)?謝謝
cdma模塊的發(fā)數(shù)據(jù)管腳一直為低!
數(shù)傳電臺
請教關(guān)于藍(lán)牙接收數(shù)據(jù)率過低的可能原因
免費(fèi)注冊為維庫電子開發(fā)網(wǎng)會員,參與電子工程師社區(qū)討論,點(diǎn)此進(jìn)入


Copyright © 1998-2006 m.58mhw.cn 浙ICP證030469號