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

📄 read_b.c

📁 pic单片机的eep模块的应用.希望能够对大家有个帮助.
💻 C
字号:
#include <p18cxxx.h>
#include <EEP.h>

/********************************************************************
*     Function Name:    Read_b_eep                                 *
*     Return Value:     contents of EEDATA register                *
*     Parameters:       unsigned int add                           *
*     Description:      Read single byte from Internal EEP         *
********************************************************************/
#if defined (EEP_V1)		//	128 byte EEP
unsigned char Read_b_eep( unsigned int badd )
{
	EEADR = (badd & 0x07f);
	EECON1bits.CFGS = 0;
	EECON1bits.EEPGD = 0;
	EECON1bits.RD = 1;
	return ( EEDATA );              // return with read byte 
}

#elif defined (EEP_V2)	//	256 byte EEP
unsigned char Read_b_eep( unsigned int badd )
{
	EEADR = (badd & 0x0ff);
  	EECON1bits.CFGS = 0;
	EECON1bits.EEPGD = 0;
	EECON1bits.RD = 1;
	return ( EEDATA );              // return with read byte
}

#elif defined (EEP_V3)				// 1024 byte EEP	
unsigned char Read_b_eep( unsigned int badd )
{
	EEADRH = (badd >> 8) & 0x03;
	EEADR = (badd & 0x0ff);
  	EECON1bits.CFGS = 0;
	EECON1bits.EEPGD = 0;
	EECON1bits.RD = 1;
	return ( EEDATA );              // return with read byte 
}
#endif

⌨️ 快捷键说明

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