read_b.c
来自「pic单片机的eep模块的应用.希望能够对大家有个帮助.」· C语言 代码 · 共 41 行
C
41 行
#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 + =
减小字号Ctrl + -
显示快捷键?