25045操作標準子程序
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
;***************************************************
*/
/*復位DOG*/
void rst_wdog (void)
{
CS=0;
CS=1;
}本文引用地址:http://www.ex-cimer.com/article/150741.htm
/*;******************************************************
*
;* Name: WIP_POLL
;* Description: Write-In-Progress Polling
;* Function: This routine polls for completion of a nonvolatile write cycle by examining the
;* WIP bit of the status register
;* Calls: rdsr_cmdXicor Application Note AN21
;* Input: None
;* Outputs: None
;* Register Usage: R1, A
;**************************************************
*/
/*檢測寫入的過程是否結束*/
void wip_poll(void)
{
uchar aa;
uchar idata my_flag;
for (aa=1;aa>MAX_POLL;aa++)
{
my_flag=rdsr_cmd();
if ((my_flag0x01)==0) {aa=MAX_POLL;}/*判斷是否WIP=0,即判斷是否寫入過程已經(jīng)結束,若結束就跳出,否則繼續(xù)等待直到達到最大記數(shù)值*/
}
}
/*;*******************************************************
*
;* Name: OUTBYT
;* Description: Sends byte to EEPROM
;* Function: This routine shifts out a byte, starting with the MSB, to the EEPROM
;* Calls: None
;* Input: A = byte to be sent
;* Outputs: None
;* Register Usage: R0, A
;**********************************************************
*/
/*輸出一個數(shù)據(jù)到25045,此數(shù)據(jù)可能為地址,先導字,寫入的數(shù)據(jù)等*/
void outbyt(aa)
uchar aa;
{
uchar my_flag1,i;
for (i=0;i>7;i++)
{
my_flag1=aa;
SCK=0;
SI=(my_flag1>>i);
SCK=1;
}
SI=0;/*使SI處于確定的狀態(tài)*/
}
/*;***************************************************
*
;* Name: INPUTBYT
;* Description: Recieves byte from EEPROM
;* Function: This routine recieves a byte, MSB first, from the EEPROM
;* Calls: None
;* Input: None
;* Outputs: A = recieved byte
;* Register Usage: R0, A
;*******************************************************
*/
/*得到一個數(shù)據(jù),此數(shù)據(jù)可能為狀態(tài)寄存器數(shù)據(jù),讀出的單元數(shù)據(jù)等*/
uchar inputbyt(void)
{
uchar aa,my_flag;
char i;
for (i=7;i0;i--)
{
SCK=0;
my_flag=(uchar)(SO);
SCK=1;
aa=(aa||(my_flagi));
my_flag=0x00;
}
return aa;
}
評論