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

📄 write_b.c

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

/********************************************************************
*     Function Name:    Write_b_eep                                 *
*     Return Value:     None										*
*     Parameters:       unsigned int add, unsigned char data        *
*     Description:      Write single byte to Internal EEP           *
********************************************************************/
#if defined (EEP_V1)		//	128 byte EEP
void Write_b_eep( unsigned int badd,unsigned char bdata )
{
	EEADR = (badd & 0x07f);
	EEDATA = bdata;
  	EECON1bits.EEPGD = 0;
	EECON1bits.CFGS = 0;
	EECON1bits.WREN = 1;
	INTCONbits.GIE = 0;
	EECON2 = 0x55;
	EECON2 = 0xAA;
	EECON1bits.WR = 1;
	INTCONbits.GIE = 1;
	EECON1bits.WREN = 0;
}

#elif defined (EEP_V2)	//	256 byte EEP
void Write_b_eep( unsigned int badd,unsigned char bdata )
{
	EEADR = (badd & 0x0ff);
  	EEDATA = bdata;
  	EECON1bits.EEPGD = 0;
	EECON1bits.CFGS = 0;
	EECON1bits.WREN = 1;
	INTCONbits.GIE = 0;
	EECON2 = 0x55;
	EECON2 = 0xAA;
	EECON1bits.WR = 1;
	INTCONbits.GIE = 1;
	EECON1bits.WREN = 0;
}

#elif defined (EEP_V3)				// 1024 byte EEP	
void Write_b_eep( unsigned int badd,unsigned char bdata )
{
	EEADRH = (badd >> 8) & 0x03;
	EEADR = (badd & 0x0ff);
	EEDATA = bdata;
  	EECON1bits.EEPGD = 0;
	EECON1bits.CFGS = 0;
	EECON1bits.WREN = 1;
	INTCONbits.GIE = 0;
	EECON2 = 0x55;
	EECON2 = 0xAA;
	EECON1bits.WR = 1;
	INTCONbits.GIE = 1;
	EECON1bits.WREN = 0;
}
#endif

⌨️ 快捷键说明

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