日本黄色一级经典视频|伊人久久精品视频|亚洲黄色色周成人视频九九九|av免费网址黄色小短片|黄色Av无码亚洲成年人|亚洲1区2区3区无码|真人黄片免费观看|无码一级小说欧美日免费三级|日韩中文字幕91在线看|精品久久久无码中文字幕边打电话

當(dāng)前位置:首頁 > 單片機(jī) > 單片機(jī)
[導(dǎo)讀] 25045操作標(biāo)準(zhǔn)子程序# include # include # define uchar unsigned char# define uint unsigned intsbit SO=P1^1;/*25045輸出*/sbit SI=P1^2;/*25045輸入*/sbitSCK=P1^3;/*25045時鐘*/sbit CS=P1^4;/*2

25045操作標(biāo)準(zhǔn)子程序

# include
# include
# define uchar unsigned char
# define uint unsigned int
sbit SO=P1^1;/*25045輸出*/
sbit SI=P1^2;/*25045輸入*/
sbitSCK=P1^3;/*25045時鐘*/
sbit CS=P1^4;/*25045片選*/
uchar code WREN_INST=0X06;
/* Write enable latch instruction (WREN)*/
uchar code WRDI_INST=0X04;
/* Write dISAble latch instruction (WRDI)*/
uchar code WRSR_INST=0X01;
/* Write status register instruction (WRSR)*/
uchar code RDSR_INST=0X05;
/* Read status register instruction (RDSR)*/
uchar code WRITE_INST=0X02;
/* Write memory instruction (WRITE)*/
/*寫入25045的先導(dǎo)字,應(yīng)當(dāng)為0000A010,其中的A為寫入25045的高位地址
將此WRITE_INST和寫入高位地址相或后即為正確的寫先導(dǎo)字*/
uchar code READ_INST=0X03;
/* Read memory instruction (READ)*/
/*讀出25045的先導(dǎo)字,應(yīng)當(dāng)為0000A011,其中的A為讀出25045的高位地址
將此READ_INST和讀出高位地址相或后即為正確的讀先導(dǎo)字*/
uint code BYTE_ADDR=0X55;
/* Memory address for byte mode operations*/
uchar code BYTE_DATA=0X11;
/*Data byte for byte write operation*/
uint code PAGE_ADDR=0X1F;
/* Memory address for page mode operations*/
/*頁面寫入的其始地址*/
uchar code PAGE_DATA1=0X22;
/* 1st data byte for page write operation*/
uchar code PAGE_DATA2=0X33;
/* 2nd data byte for page write operation*/
uchar code PAGE_DATA3=0X44;
/* 3rd data byte for page write operation*/
uchar code STATUS_REG=0X20;
/* Status register,設(shè)置DOG時間設(shè)置為200毫秒,無寫保護(hù)*/
/*這是狀態(tài)寄存器的值,他的意義在于第5,第4位為WDI1,WDI0代表DOG的時間,00為1.4秒,01為600毫秒,10為200毫秒,00為disabLED
第3位和第2位為BL1,BL0,是寫保護(hù)設(shè)置位,00為無保護(hù),01為保護(hù)180-1FF,10為保護(hù)100-1FF,11為保護(hù)000-1FF.第1位為WEL,
當(dāng)他為1時代表已經(jīng)"寫使能"設(shè)置了,現(xiàn)在可以寫了,只讀位.第0位為WIP,當(dāng)他為1時代表正在進(jìn)行寫操作,是只讀*/
uchar code MAX_POLL=0x99;
/* Maximum number of polls*/
/*最大寫過程時間,確定25045的最大的寫入過程的時間*/
uchar code INIT_STATE=0x09;
/* Initialization value for control ports*/
uint code SLIC=0x30;
/* AddressLOCation of SLIC*/
void wren_cmd(void);/*寫使能子程序*/
void wrdi_cmd(void);/*寫使能復(fù)位*/
void wrsr_cmd(void);/*復(fù)位時間位和數(shù)據(jù)保護(hù)位寫入狀態(tài)寄存器*/
uchar rdsr_cmd(void);/*讀狀態(tài)寄存器*/
void byte_write(uchar aa,uint dd);/*字節(jié)寫入,aa為寫入的數(shù)據(jù),dd為寫入的地址*/
uchar byte_read(uint dd);/*字節(jié)讀出,dd為讀出的地址,返回讀出的數(shù)據(jù)*/
void page_write(uchar aa1,uchar aa2,uchar aa3,uchar aa4,uint dd);/*頁寫入*/
void sequ_read(void);/*連續(xù)讀出*/
void rst_wdog(void);/*DOG復(fù)位*/
void outbyt(uchar aa);/*輸出一個字節(jié)到25045中,不包括先導(dǎo)字等*/
uchar inputbyt();/*由25045輸入一個字節(jié),不包括先導(dǎo)字等額外的東西*/
void wip_poll(void);/*檢查寫入過程是否結(jié)束*/


/*25045操作子程序集*/
/*;*******************************************************
*
;* Name: WREN_CMD
;* Description: Set write enable latch
;* Function: This routine sends the command to enable writes to the EEPROM memory array or
;* status register
;* Calls: outbyt
;* Input: None
;* Outputs: None
;* Register Usage: A
;*****************************************************
*/
/*寫使能子程序*/
void wren_cmd(void)
{
uchar aa;
SCK=0;/* Bring SCK low */
CS=0;/* Bring /CS low */
aa=WREN_INST;
outbyt(aa);/* Send WREN instruction */
SCK=0;/* Bring SCK low */
CS=1;/* Bring /CS high */
}

/*;***********************************************************
*
;* Name: WRDI_CMD
;* Description: Reset write enable latch
;* Function: This routine sends the command to disable writes to the EEPROM memory array or
;* status register
;* Calls: outbyt
;* Input: None
;* Outputs: None
;* Register Usage: A
;***********************************************************
*/
/*寫使能復(fù)位子程序*/
void wrdi_cmd(void)
{
uchar aa;
SCK=0;/* Bring SCK low */
CS=0;/* Bring /CS low */
aa=WRDI_INST;
outbyt(aa);/* Send WRDI instruction */
SCK=0;/* Bring SCK low */
CS=1;/* Bring /CS high */
}


/*;********************************************************
*
;* Name: WRSR_CMD
;* Description: Write Status Register
;* Function: This routine sends the command to write the WD0, WD1, BP0 and BP0 EEPROM
;* bits in the status register
;* Calls: outbyt, wip_poll
;* Input: None
;* Outputs: None
;* Register Usage: A
;********************************************
*/
/*寫狀態(tài)寄存器子程序*/
void wrsr_cmd(void)
{
uchar aa;
SCK=0;/* Bring SCK low */
CS=0;/* Bring /CS low */
aa=WRSR_INST;
outbyt(aa) ;/* Send WRSR instruction */
aa=STATUS_REG;
outbyt(aa);/* Send status register */
SCK=0;/* Bring SCK low */
CS=1;/* Bring /CS high */
wip_poll();/* Poll for completion of write cycle */
}

/*;*************************************************************
*
;* Name: RDSR_CMD
;* Description: Read Status Register
;* Function: This routine sends the command to read the status register
;* Calls: outbyt, inputbyt
;* Input: None
;* Outputs: A = status registerXicor Application Note AN21
;* Register Usage: A
;*******************************************************
*/
/*讀狀態(tài)寄存器,讀出的數(shù)據(jù)放入到aa中*/
uchar rdsr_cmd (void)
{
uchar aa;
SCK=0;
CS=0;
aa=RDSR_INST;
outbyt(aa);
aa=inputbyt();
SCK=0;
CS=1;
return aa;
}

/*;*******************************************************
*
;* Name: BYTE_WRITE
;* Description: Single Byte Write
;* Function: This routine sends the command to write a single byte to the EEPROM memory
array
;* Calls: outbyt, wip_poll
;* Input: None
;* Outputs: None
;* Register Usage: A, B
;**********************************************************
*/

/*字節(jié)寫入,aa為寫入的數(shù)據(jù),dd為寫入的地址,對于25045而言為000-1FF*/
void byte_write(aa,dd)
uchar aa;
uint dd;
{
SCK=0;
CS=0;
outbyt((((uchar)(dd-0XFF))<<3)|WRITE_INST);/* Send WRITE instruction including MSB of address */
/*將高位地址左移3位與寫入先導(dǎo)字相或,得到正確的先導(dǎo)字寫入25045*/
outbyt((uchar)(dd));
/*輸出低位地址到25045*/
outbyt(aa);
/*寫入數(shù)據(jù)到25045的對應(yīng)單元*/
SCK=0;
CS=1;
wip_poll();
/*檢測是否寫完*/
}


/*;********************************************************
*
;* Name: BYTE_READ
;* Description: Single Byte Read
;* Function: This routine sends the command to read a single byte from the EEPROM memory
array
;* Calls: outbyt, inputbyt
;* Input: None
;* Outputs: A = read byte
;* Register Usage: A, BXICor Application Note AN21
;********************************************************
*/
/*字節(jié)讀出,其中dd為讀出的地址,返回的值為讀出的數(shù)據(jù)*/
uchar byte_read(dd)
uint dd;
{
ucharCC;
SCK=0;
CS=0;
outbyt((((uchar)(dd-0XFF))<<3)|READ_INST);/* Send READ_INST instruction including MSB of address */
/*將高位地址左移3位與讀出先導(dǎo)字相或,得到正確的先導(dǎo)字寫入25045*/
outbyt((uchar)(dd));
/*輸出低位地址到25045*/
cc=inputbyt();/*得到讀出的數(shù)據(jù)*/
SCK=0;
CS=1;
return cc;
}


/*;**********************************************
*
;* Name: PAGE_WRITE
;* Description: Page Write
;* Function: This routine sends the command to write three consecutive bytes to the EEPROM
;* memory array using page mode
;* Calls: outbyt, wip_poll
;* Input: None
;* Outputs: None
;* Register Usage: A, B
;*****************************************************
*/
/*頁面寫入,其中aa1,aa2,aa3,aa4為需要寫入的4個數(shù)據(jù)(最大也就只能一次寫入4個字,dd為寫入的首地址*/
void page_write(aa1,aa2,aa3,aa4,dd)
uchar aa1,aa2,aa3,aa4;
uint dd;
{
SCK=0;
CS=0;
outbyt((((uchar)(dd-0XFF))<<3)|WRITE_INST);/* Send WRITE instruction including MSB of address */
/*將高位地址左移3位與寫入先導(dǎo)字相或,得到正確的先導(dǎo)字寫入25045*/
outbyt((uchar)(dd));
/*寫入低位地址到25045*/
outbyt(aa1);
/*寫入數(shù)據(jù)1到25045的對應(yīng)單元*/
outbyt(aa2);
/*寫入數(shù)據(jù)2到25045的對應(yīng)單元*/
outbyt(aa3);
/*寫入數(shù)據(jù)3到25045的對應(yīng)單元*/
outbyt(aa4);
/*寫入數(shù)據(jù)4到25045的對應(yīng)單元*/
SCK=0;
CS=1;
wip_poll();
}


/*;********************************************
*
;* Name: SEQU_READ
;* Description: Sequential Read
;* Function: This routine sends the command to read three consecutive bytes from the EEPROM
;* memory array using sequential mode
;* Calls: outbyt, inputbyt
;* Input: None
;* Outputs: A = last byte read
;* Register Usage: A, B
;*********************************************************
*/
/*連續(xù)讀出,由于函數(shù)的返回值只能為1個,對于連續(xù)讀出的數(shù)據(jù)只能使用指針作為函數(shù)的返回值才能做到返回一系列的數(shù)組*/
/*sequ_read:*/
unsigned int *page_read(n,dd)
uchar n;/*n是希望讀出的數(shù)據(jù)的個數(shù),n<=11*/
unsigned int dd;/*dd是讀出數(shù)據(jù)的首地址*/
{
uchar i;
uchar pp[10];
unsigned int *pt=pp;
SCK=0;
CS=0;
outbyt((((uchar)(dd-0XFF))<<3)|READ_INST);
for (i=0;i{
pp[i]=inputbyt();
}
return (pt);
}
/*調(diào)用的方法如下*/
/*unsigned int *p;*/
/*p=page_read(4,100);*/
/*a=*(p)*/
/*b=*(p+1)*/
/*c=*(p+2)*/
/*d=*(p+3)*/
/*abcd中存放25045中由100地址開始的4個數(shù)據(jù)*/
/* Send WRITE */
/*mov DPTR, #PAGE_ADDR ; Set address of 1st byte to be read
clr sck ; Bring SCK low
clr cs ; Bring /CS low
mov A, #READ_INST
mov B, DPH
mov C, B.0
mov ACC.3, C
lcall outbyt ; Send READ instruction with MSB of address
mov A, DPL
lcall outbyt ; Send low order address byte
lcall inputbyt ; Read 1st data byte
lcall inputbyt ; Read 2nd data byte
lcall inputbyt ; Read 3rd data byte
clr sck ; Bring SCK low
setb cs ; Bring /CS high
ret*/
/*;*******************************************************
*
;* Name: RST_WDOG
;* Description: Reset Watchdog Timer
;* Function: This routine resets the watchdog timer without sending a command
;* Calls: None
;* Input: None
;* Outputs: None
;* Register Usage: None
;***************************************************
*/
/*復(fù)位DOG*/
void rst_wdog (void)
{
CS=0;
CS=1;
}

本站聲明: 本文章由作者或相關(guān)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點(diǎn),本站亦不保證或承諾內(nèi)容真實性等。需要轉(zhuǎn)載請聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請及時聯(lián)系本站刪除。
換一批
延伸閱讀

為了提升設(shè)計效率和運(yùn)行安全性 ,對DL/T 834—2023《火力發(fā)電廠汽輪機(jī)防進(jìn)水和冷蒸汽導(dǎo)則》與DL/T 834—2003 《火力發(fā)電廠汽輪機(jī)防進(jìn)水和冷蒸汽導(dǎo)則》的設(shè)計、運(yùn)行和檢驗及維護(hù)要求進(jìn)行了對比分析 , 總...

關(guān)鍵字: 標(biāo)準(zhǔn) 疏水 冷蒸汽 發(fā)電廠

電磁兼容(EMC)是指在同一電磁環(huán)境中,不同設(shè)備或系統(tǒng)能夠正常工作且互不干擾的狀態(tài)。在現(xiàn)代電子和通信領(lǐng)域,EMC是一個至關(guān)重要的概念,它不僅影響設(shè)備的性能,還關(guān)系到整個系統(tǒng)的穩(wěn)定性和安全性。為了確保設(shè)備的EMC,各國都制...

關(guān)鍵字: 電磁兼容 EMC 標(biāo)準(zhǔn)

無線充電技術(shù),作為現(xiàn)代科技領(lǐng)域的一項創(chuàng)新,正逐步改變著我們的生活方式。從智能手機(jī)到電動汽車,無線充電的應(yīng)用場景日益廣泛,為用戶提供了前所未有的便捷性。然而,盡管無線充電技術(shù)發(fā)展迅速,其在標(biāo)準(zhǔn)和能效方面仍面臨諸多瓶頸,這些...

關(guān)鍵字: 無線充電 能效 標(biāo)準(zhǔn)

隨著無人機(jī)的普及,越來越多的人開始使用無人機(jī)進(jìn)行各種飛行任務(wù),但是不當(dāng)?shù)氖褂脮o公共安全和社會秩序帶來潛在的風(fēng)險,因此對于無人機(jī)使用的規(guī)定也變得越來越嚴(yán)格。本文將介紹無人機(jī)使用的標(biāo)準(zhǔn)和規(guī)定,以幫助大家正確使用無人機(jī)。

關(guān)鍵字: 無人機(jī) 標(biāo)準(zhǔn) UAV

智能家居作為新興領(lǐng)域,逐漸走入了人們的生活。智能家居系統(tǒng)是利用先進(jìn)的計算機(jī)技術(shù)、網(wǎng)絡(luò)通訊技術(shù)、智能云端控制、綜合布線技術(shù)、醫(yī)療電子技術(shù)依照人體工程學(xué)原理,融合個性需求,將與家居生活有關(guān)的各個子系統(tǒng)如安防、燈光控制、窗簾控...

關(guān)鍵字: 智能家居 標(biāo)準(zhǔn)

摘要:深度調(diào)峰就是受電網(wǎng)負(fù)荷峰谷差較大影響而導(dǎo)致機(jī)組降出力、超過基本調(diào)峰范圍進(jìn)行調(diào)峰的一種運(yùn)行方式,深度調(diào)峰的負(fù)荷范圍超過該機(jī)組鍋爐最低穩(wěn)燃負(fù)荷,一般調(diào)峰深度為60%~70%BMCR?,F(xiàn)從實際出發(fā),闡述泰州發(fā)電廠#1機(jī)組...

關(guān)鍵字: 深度調(diào)峰 操作 穩(wěn)燃

因為5G涵蓋內(nèi)容更豐富,上述三個5G專利池側(cè)重點(diǎn)也不同:Avanci側(cè)重汽車和物聯(lián)網(wǎng);Sisvel側(cè)重手機(jī)等終端領(lǐng)域;Alium側(cè)重?zé)o線接入網(wǎng)RAN。

關(guān)鍵字: 5G 標(biāo)準(zhǔn) 必要專利

摘 要:對電流和電壓信號進(jìn)行諧波分析 ,確定諧波的嚴(yán)重程度和特征是防范和治理高次諧波的第一步 。據(jù)此研究了應(yīng)用Matlab 軟件中的快速傅里葉變換來求取供電系統(tǒng)電流電壓信號的諧波幅值和相位的方法 ,并編成子程序 ,應(yīng)...

關(guān)鍵字: 諧波分析 供電系統(tǒng) 子程序

操作維護(hù)管理(Operation Administration and Maintenance)是指根據(jù)運(yùn)營商網(wǎng)絡(luò)運(yùn)營的實際需要,通常將網(wǎng)絡(luò)的管理工作劃分為3大類:操作(Operation)、管理(Administrat...

關(guān)鍵字: 操作 管理 維護(hù)

現(xiàn)在我著重介紹虛擬存儲在數(shù)字視頻網(wǎng)絡(luò)中的應(yīng)用。數(shù)字視頻網(wǎng)絡(luò)對廣播電視行業(yè)來說已經(jīng)不是一個陌生的概念了,由于它在廣播電視技術(shù)數(shù)字化進(jìn)程中起到了重要的作用,國內(nèi)各級電視臺對其給予極大的關(guān)注,并且開始構(gòu)造和應(yīng)用這類系統(tǒng),在數(shù)字...

關(guān)鍵字: 數(shù)字視頻網(wǎng)絡(luò) 工作站 操作
關(guān)閉