日韩床上生活一级视频|能看毛片的操逼网站|色悠悠网站在线观看视频|国产免费观看A淫色免费|国产av久久久久久久|免费A级视频美女网站黄|国产毛片av日韩小黄片|热久久免费国产视频|中文字幕无码色色|成人在线视频99久久久

機電之家資源網(wǎng)
單片機首頁|單片機基礎(chǔ)|單片機應(yīng)用|單片機開發(fā)|單片機文案|軟件資料下載|音響制作|電路圖下載 |嵌入式開發(fā)
培訓(xùn)信息
贊助商
93C46 C示例程序
93C46 C示例程序
 更新時間:2008-7-27 16:02:00  點擊數(shù):4
【字體: 字體顏色
/*通用93c06-93c86系列使用說明
93c06=93c4693c56=93c6693c76=93c86*/
//dipx 可以自行定義
#i nclude <AT89X52.H>
#i nclude "intrins.h"
/*-----------------------------------------------------
SPI93cXX系列時序函數(shù)調(diào)用(普通封裝)
調(diào)用方式:自行定義﹫2001/05/12
函數(shù)說明:私有函數(shù),封裝各接口定義
-----------------------------------------------------*/
/*#define di_93 dip3
#define sk_93 dip2
#define cs_93 dip1
#define do_93 dip4
#define gnd_93 dip5
#define org_93 dip6*/
sbit cs_93=0xA3;
sbit sk_93=0xA4;
sbit di_93=0xA5;
sbit do_93=0xA6;
sbit org_93=0xA7;
/*
sbit spi_cs  = 0xA3;
sbit spi_sk  = 0xA4;
sbit spi_di  = 0xA5;
sbit spi_do  = 0xA6;
sbit spi_org = 0xA7;*/


/*-----------------------------------------------------
SPI93cXX系列時序函數(shù)調(diào)用(普通封裝)
調(diào)用方式:void high46(void) ---高8位函數(shù)調(diào)用
void low46(void) ---低8位函數(shù)調(diào)用﹫2001/05/12
函數(shù)說明:私有函數(shù),SPI專用93c46普通封裝驅(qū)動程序
-----------------------------------------------------*/
void high46(void)
{
di_93=1;
sk_93=1;
_nop_();
sk_93=0;
_nop_();
}
void low46(void)
{
di_93=0;
sk_93=1;
_nop_();
sk_93=0;
_nop_();
}
void wd46(unsigned char dd)
{
unsigned char i;
for (i=0;i<8;i++)
{
if (dd>=0x80)
high46();
else
low46();
dd=dd<<1;
}
}
unsigned char rd46(void)
{
unsigned char i,dd;
do_93=1;
for (i=0;i<8;i++)
{
dd<<=1;
sk_93=1;
_nop_();
sk_93=0;
_nop_();
if (do_93)
dd|=1;
}
return(dd);
}

/*-----------------------------------------------------
SPI93cXX系列時序函數(shù)調(diào)用(特殊封裝)
調(diào)用方式:自行定義﹫2001/05/12
函數(shù)說明:私有函數(shù),特殊封裝各接口定義
-----------------------------------------------------
#define di_93a dip5
#define sk_93a dip4
#define cs_93a dip3
#define do_93a dip6
#define gnd_93a dip7
#define vcc_93a out_vcc(2)
sbit cs_93a=P1^0;
sbit sk_93a=P1^1;
sbit di_93a=P1^2;
sbit do_93a=P1^3;
/*-----------------------------------------------------
SPI93cXX系列時序函數(shù)調(diào)用(特殊封裝)
調(diào)用方式:void high46a(void) ---高8位函數(shù)調(diào)用
void low46a(void) ---低8位函數(shù)調(diào)用﹫2001/05/12
函數(shù)說明:私有函數(shù),SPI專用93c46特殊封裝驅(qū)動程序
-----------------------------------------------------
void high46a(void)
{
di_93a=1;
sk_93a=1;_nop_();
sk_93a=0;_nop_();
}
void low46a(void)
{
di_93a=0;
sk_93a=1;_nop_();
sk_93a=0;
_nop_();
}
void wd46a(unsigned char dd)
{
unsigned char i;
for (i=0;i<8;i++)
{
if (dd>=0x80) high46a();
else low46a();
dd=dd<<1;
}
}
unsigned char rd46a(void)
{
unsigned char i,dd;
do_93a=1;
for (i=0;i<8;i++)
{
dd<<=1;
sk_93a=1;_nop_();
sk_93a=0;_nop_();
if (do_93a) dd|=1;
}
return(dd);
}
/*-----------------------------------------------------
SPI93c46系列函數(shù)調(diào)用(舉例)
調(diào)用方式:bit write93c56_word(unsigned int address,unsigned int dat) ﹫2001/05/12
函數(shù)說明:私有函數(shù),SPI專用
-----------------------------------------------------*/
void ewen46(void)
{
_nop_();
cs_93=1;
high46();
wd46(0x30);
cs_93=0;
}

unsigned char eral_46()
{
   data unsigned char temp1;
   data unsigned int temp2;
   cs_93=0;
   sk_93=0;
//spi_org=1;
   cs_93=1;
   ewen46();
   _nop_();
   cs_93=1;
   _nop_();
   high46();
   wd46(0x20);
   wd46(0x20);
   cs_93=0;
   _nop_();
   cs_93=1;
   temp1=1;
   temp2=50000;
   while(!do_93)
   {
     temp2=temp2-1;
  if(temp2==0)
  {
    temp1=0;
    break;
  }
   }
   cs_93=0;
   return temp1;
}


unsigned int read93c46_word(unsigned char address)
{
unsigned int dat;
unsigned char dat0,dat1;
//gnd_93a=0;
//gnd_93=0;
cs_93=sk_93=0;
//org_93=1;
cs_93=1;_nop_();
//address=address<<1;
//address=address>>1;
address=address|0x80;
address=address|0x80;
high46();
wd46(address);
dat1=rd46();
dat0=rd46();
cs_93=0;
dat=dat1*256+dat0;
return(dat);
}
bit write93c46_word(unsigned char address,unsigned int dat)
{
unsigned char e,time,temp=address;
e=0;
while (e<3)
{
//gnd_93a=0;
//gnd_93=0;
cs_93=sk_93=0;
org_93=1;
cs_93=1;
ewen46();
_nop_();
cs_93=1;
_nop_();
high46();
address<<=1;//??
address|=0x80;
address>>=1;//??
address|=0x40;
wd46(address);
wd46(dat/256);
wd46(dat%256);
cs_93=0;
_nop_();
cs_93=1;
time=0;
do_93=1;
while (1)
{
if (do_93==1)
break;
if (time>20)
break;
time++;
}
cs_93=0;
if (read93c46_word(temp)==dat)
{
return(0);
}
e++;
}
return(1);
}
/*-----------------------------------------------------
SPI93c57系列函數(shù)調(diào)用(舉例)
調(diào)用方式:bit write93c57_word(unsigned int address,unsigned int dat) ﹫2001/05/12
函數(shù)說明:私有函數(shù),SPI專用
-----------------------------------------------------
void ewen57(void)
{
_nop_();
cs_93=1;
dip7=0;
high46();
low46();
wd46(0x60);
cs_93=0;
}
unsigned int read93c57_word(unsigned int address)
{
unsigned int dat;
unsigned char dat0,dat1;
gnd_93=0;
cs_93=sk_93=0;
org_93=1;
cs_93=1;
address=address>>1;
high46();
high46();
wd46(address);
dat1=rd46();
dat0=rd46();
cs_93=0;
dat=dat1*256+dat0;
return(dat);
}
bit write93c57_word(unsigned int address,unsigned int dat)
{
unsigned char e;
unsigned int temp=address;
e=0;
while (e<3)
{
gnd_93=0;
cs_93=sk_93=0;
org_93=1;
cs_93=1;
ewen57();
cs_93=1;
_nop_();
high46();
low46();
address>>=1;
address|=0x80;
wd46(address);
wd46(dat/256);
wd46(dat%256);
cs_93=0;
_nop_();
cs_93=1;
time=0;
do_93=1;
while (1)
{
if (do_93==1) break;
if (time>20) break;
}
cs_93=0;
if (read93c57_word(temp)==dat)
{
return(0);
}
e++;
}
return(1);
}
/*-----------------------------------------------------
SPI93c56系列函數(shù)調(diào)用(舉例)
調(diào)用方式:bit write93c56_word(unsigned int address,unsigned int dat) ﹫2001/05/12
函數(shù)說明:私有函數(shù),SPI專用
-----------------------------------------------------
void ewen56(void)
{
_nop_();
cs_93=1;
high46();
low46();
low46();
wd46(0xc0);
cs_93=0;
}
unsigned int read93c56_word(unsigned char address)
{
unsigned int dat;
unsigned char dat0,dat1;
gnd_93=0;
cs_93=sk_93=0;
org_93=1;
cs_93=1;
address=address>>1;
high46();
high46();
low46();
wd46(address);
dat1=rd46();
dat0=rd46();
cs_93=0;
dat=dat1*256+dat0;
return(dat);
}
bit write93c56_word(unsigned char address,unsigned int dat)
{
unsigned char e;
unsigned int temp=address;
e=0;
while (e<3)
{
gnd_93=0;
cs_93=sk_93=0;
org_93=1;
cs_93=1;
ewen56();
_nop_();
cs_93=1;
_nop_();
high46();
low46();
high46();
address>>=1;
wd46(address);
wd46(dat/256);
wd46(dat%256);
cs_93=0;
_nop_();
cs_93=1;
TH0=0;
time=0;
do_93=1;
while (1)
{
if (do_93==1) break;
if (time) break;
}
cs_93=0;
if (read93c56_word(temp)==dat)
{
return(0);
}
e++;
}
return(1);
}
/*-----------------------------------------------------
SPI93c76與SPI93c86系列函數(shù)調(diào)用(舉例)
調(diào)用方式:bit write93c76_word(unsigned int address,unsigned int dat) ﹫2001/05/12
函數(shù)說明:私有函數(shù),SPI專用
-----------------------------------------------------
void ewen76(void)
{
_nop_();
cs_93=1;
dip7=1;
high46();
low46();
low46();
high46();
high46();
wd46(0xff);
cs_93=0;
}
unsigned int read93c76_word(unsigned int address)
{
unsigned char dat0,dat1;
gnd_93=0;
cs_93=sk_93=0;
org_93=1;
cs_93=1;
address>>=1;
high46();
high46();
low46();
if((address&0x200)==0x200) high46();
else low46();
if ((address&0x100)==0x100) high46();
else low46();
wd46(address);
dat1=rd46();
dat0=rd46();
cs_93=0;
return(dat1*256|dat0);
}
bit write93c76_word(unsigned int address,unsigned int dat)
{
unsigned char e;
unsigned int temp=address;
e=0;
address>>=1;
while (e<3)
{
gnd_93=0;
cs_93=sk_93=0;
org_93=1;
cs_93=1;
ewen76();
_nop_();
cs_93=1;
high46();
low46();
high46();
if((address&0x200)==0x200) high46();
else low46();
if ((address&0x100)==0x100) high46();
else low46();
wd46(address);
wd46(dat/256);
wd46(dat%256);
cs_93=0;_nop_();cs_93=1;
time=0;do_93=1;
while (1)
{
if (do_93==1) break;
if (time>10) break;
}
cs_93=0;
e++;
}
return(1);
}
/*-----------------------------------------------------
主函數(shù)調(diào)用(舉例)
調(diào)用方式:main() ﹫2001/05/12
函數(shù)說明:私有函數(shù),SPI專用
-----------------------------------------------------*/
main()
{
  bit b;
  unsigned int i;
  unsigned int j[32];
  eral_46();
  for(i=0;i<32;i++)
  j[i]=read93c46_word(i);
  for(i=0;i<32;i++)
    write93c46_word(i,0x0910);
  i=0;
  b=write93c46_word(i,0x1213);
  j[i]=read93c46_word(i);
  i=1;
  b=write93c46_word(i,0x1122);
  j[i]=read93c46_word(i);
  i=2;
  b=write93c46_word(i,0x1344);
  j[i]=read93c46_word(i);
  i=3;
  b=write93c46_word(i,0x1526);
  j[i]=read93c46_word(i);
  i=4;
  b=write93c46_word(i,0xccde);
  j[i]=read93c46_word(i);
  P2_7=0;
}

  • 上一篇: Keil C51常用功能模塊使用說明(1)
  • 下一篇: 實時時鐘芯片HT1380讀寫c程序
  • 發(fā)表評論   告訴好友   打印此文  收藏此頁  關(guān)閉窗口  返回頂部
    熱點文章
     
    推薦文章
     
    相關(guān)文章
    網(wǎng)友評論:(只顯示最新5條。)
    關(guān)于我們 | 聯(lián)系我們 | 廣告合作 | 付款方式 | 使用幫助 | 機電之家 | 會員助手 | 免費鏈接

    點擊這里給我發(fā)消息66821730(技術(shù)支持)點擊這里給我發(fā)消息66821730(廣告投放) 點擊這里給我發(fā)消息41031197(編輯) 點擊這里給我發(fā)消息58733127(審核)
    本站提供的機電設(shè)備,機電供求等信息由機電企業(yè)自行提供,該企業(yè)負(fù)責(zé)信息內(nèi)容的真實性、準(zhǔn)確性和合法性。
    機電之家對此不承擔(dān)任何保證責(zé)任,有侵犯您利益的地方請聯(lián)系機電之家,機電之家將及時作出處理。
    Copyright 2007 機電之家 Inc All Rights Reserved.機電之家-由機電一體化網(wǎng)更名-聲明
    電話:0571-87774297 傳真:0571-87774298
    杭州濱興科技有限公司提供技術(shù)支持

    主辦:杭州市高新區(qū)(濱江)機電一體化學(xué)會
    中國行業(yè)電子商務(wù)100強網(wǎng)站

    網(wǎng)站經(jīng)營許可證:浙B2-20080178-1