ht48f06edemo.c

来自「对合泰单片机的内部EEPROGRAM读写的例程」· C语言 代码 · 共 102 行

C
102
字号
/*******************************************************************************
*                                                                            
*	Filename:EEPROM.c
*
*  	Author:			Ricky 
*  	Company:    	Holtek
*	Case:
*	Device:			HT48F06E
*   Date:       	2007/01/18
*	Modifier:		Maggie (Holtek)
*	Modify Date:	2007/01/18
*   Visions:   		1.0
*   Compiler:		HT-IDE3000 V6.5 
*	Clock:			4MHz Cystral 
*	
********************************************************************************
*
*	Function:
*		HT48F06E Read/Write EEPROM data memory Example Program
*
********************************************************************************
*
*	Pin assignemt:
*
*******************************************************************************/
#include "HT48F06EDEMO.h"

/******************************************************************************/
/*Main program area		  													  */
/******************************************************************************/
void main(void)
{
	UC EEADDR;
	
	_bp = 1;
	_mp1 = 0x40;
	
	EWEN();
	
	ERAL();												//Test1, Erase All test
	for(EEADDR=0 ; EEADDR<0x80 ; EEADDR++)
	{
		if(READ(EEADDR) != 0xff)
			goto Error;
	}
	
	ERAL();												//Test2, Write All using 55 test
	WRAL(0x55);
	for(EEADDR=0 ; EEADDR<0x80 ; EEADDR++)
	{
		if(READ(EEADDR) != 0x55)
			goto Error;
	}
			
	ERAL();												//Test3, Write All using AA test
	WRAL(0xaa);
	for(EEADDR=0 ; EEADDR<0x80 ; EEADDR++)
	{
		if(READ(EEADDR) != 0xaa)
			goto Error;
	}
	
	for(EEADDR=0 ; EEADDR<0x80 ; EEADDR=EEADDR+2)		//Test4, Write one by one using 55 and AA test
	{
		WRITE(EEADDR, 0x55);
		WRITE(EEADDR+1, 0xaa);		
	}
	
	for(EEADDR=0 ; EEADDR<0x80 ; EEADDR=EEADDR+2)
	{
		if(READ(EEADDR) != 0x55)
			goto Error;
		if(READ(EEADDR+1) != 0xaa)
			goto Error;			
	}
	
	for(EEADDR=0 ; EEADDR<0x80 ; EEADDR++)				//Test5, Write one by one using ADDRESS as the writing data test
	{
		WRITE(EEADDR, EEADDR);
	}
		
	for(EEADDR=0 ; EEADDR<0x80 ; EEADDR++)
	{
		if(READ(EEADDR) != EEADDR)
			goto Error;
	}	
	
//----- if all pass, program will run here. User can set breakpoint here
	OK:
		EWDS();
		while(1);		

//----- if any Error, program will jump here. User can set breakpoint here
	Error:
		EWDS();
		while(1);
}

/******************************************************************************/
/*Sub program area		  													  */
/******************************************************************************/

⌨️ 快捷键说明

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