⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test_api.c

📁 C51 API 例子源码
💻 C
字号:
/*C**********************************************************************
* NAME:         test_api.c
*------------------------------------------------------------------------
* Copyright (c) 2004 Atmel.
*------------------------------------------------------------------------
* RELEASE:            
* REVISION:     1.0     
*------------------------------------------------------------------------
* PURPOSE: usage example of flash_eeprom_api.c
*************************************************************************/

/*_____ I N C L U D E S ________________________________________________*/
#include "flash_eeprom_api.c"

/*F***********************************************************************
* NAME: main 
*-------------------------------------------------------------------------
* PARAMS:
*-------------------------------------------------------------------------
* PURPOSE: usage example of flash_eeprom_api.c 
*-------------------------------------------------------------------------
* EXAMPLE:
*-------------------------------------------------------------------------
* NOTE: 
*-------------------------------------------------------------------------
* REQUIREMENTS: 
*************************************************************************/
void main (void)
{
int adress;
char i=0;
char data_tmp;

/* write code page example */
for(adress=0x0000;adress<0x007F;adress++)
{
/* write 0x55 between 0x0000 and 0x007F of xram */
*((unsigned char xdata*) adress)=0x55;    
}
/* copy xram page to flash at 0x1100 */
__api_wr_code_page(0x1100,0x0000,0x7F);   

/* write code byte example */
i=0;
for(adress=0x1000;adress<0x1006;adress++)
{
   /* write "ABCDEF" at 0x1000 */
   __api_wr_code_byte(adress,0x41+i++);   
}

/* read and write code byte example */
for(adress=0x1000;adress<0x1006;adress++)
{
/* copy 0x1000-0x1006 to 0x1010-0x1016 in flash memory */
   data_tmp = __api_rd_code_byte(adress);
   __api_wr_code_byte(adress+0x0010,data_tmp);
}

#ifdef ONCHIP_EEPROM
/* write eeprom byte example */
i=0;
for (adress=0x000;adress<0x400;adress++)  /* write 1Ko of eeprom */
{
   /* write a byte, write time = 10ms to 20ms */
   __api_wr_eeprom_byte(adress,i++);      
}

/* read eeprom byte example */
for (adress=0x000;adress<0x400;adress++)
{
/* copy previous writed data from eeprom to flash at 0x1200 */
   data_tmp=__api_rd_eeprom_byte(adress);
   __api_wr_code_byte(0x1200+adress,data_tmp);
}

#endif
while(1);                                 /* endless */
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -