📄 lle_eeeprom.c
字号:
#include <hidef.h> /* common defines and macros */
#include <MC9S12XEP100.h> /* derivative information */
#include "typedefs.h"
#include "lle_EEEPROM.h"
//==============================================================================
//EEE_Enable
//==============================================================================
void EEE_Enable(void)
{
FSTAT = 0x30; //clear ACCERR and PVIOL
FCCOBIX = 0x00;
FCCOB = 0x1300; //enable EEPROM Emulation Command
FSTAT_CCIF = 1; //lunch command
while(FSTAT_CCIF == 0); //wait for done
}
//==============================================================================
//EEE_Disable
//==============================================================================
void EEE_Disable(void)
{
FSTAT = 0x30; //clear ACCERR and PVIOL
FCCOBIX = 0x00;
FCCOB = 0x1400; //disable EEPROM Emulation Command
FSTAT_CCIF = 1; //lunch command
while(FSTAT_CCIF == 0); //wait for done
}
//==============================================================================
//DFLASH_Partition
//==============================================================================
void DFLASH_Partition(unsigned int DFPART, unsigned int ERPART)
{
while(FSTAT_CCIF == 0); //wait if command in progress
FSTAT = 0x30; //clear ACCERR and PVIOL
FCCOBIX = 0x00;
FCCOB = 0x2000; //Partition D-Flash Command
FCCOBIX = 0x01;
FCCOB = DFPART;
FCCOBIX = 0x02;
FCCOB = ERPART;
FSTAT_CCIF = 1; //lunch command
while(FSTAT_CCIF == 0); //wait for done
}
//==============================================================================
//DFLASH_Full_Partition
//==============================================================================
void DFLASH_Full_Partition(unsigned int DFPART, unsigned int ERPART)
{
while(FSTAT_CCIF == 0); //wait if command in progress
FSTAT = 0x30; //clear ACCERR and PVIOL
FCCOBIX = 0x00;
FCCOB = 0x0F00; //Full Partition D-Flash Command
FCCOBIX = 0x01;
FCCOB = DFPART;
FCCOBIX = 0x02;
FCCOB = ERPART;
FSTAT_CCIF = 1; //lunch command
while(FSTAT_CCIF == 0); //wait for done
}
//==============================================================================
//EEE_Init
//==============================================================================
void lle_EEE_Init(void)
{
while(FSTAT_CCIF == 0); //wait if command in progress
MMCCTL1_EEEIFRON = 1; //enable EEEIFR in memory map
FCLKDIV = EEEPROM_FDIV; //osc = 16MHz
//set ERPART, DFPART. One of following routines has to be called before
//enabling the emulated EEPROM.
DFLASH_Partition(0,16);
//DFLASH_Partition is valid in all modes. If we want to change the setting of
//DFPART and ERPART, then the appropriate nonvolatile bytes has to be erased.
//Otherwise this command is not executed. So the DFLASH is not erased during debugging
//in special mode if nonvolatile bytes are not erased manually
//(only first time when the DFPART and ERPART is set).
//DFLASH_Full_Partition(0,16);
//DFALSH_Full_Partition is valid only in unsecured special single chip mode and
//unsecured special mode. This command will set the DFPART and ERPART (nonvolatile
//bytes) and will erase whole DFLASH memory. The command is not executed in other
//modes (and data are not erased in other modes of course).
//See please document MC9S12XEP100.pdf for more information
//Full Partition D-Flash Command - page 893
//Partition D-Flash Command - page 902
EEE_Enable(); //enable EEE
}
//==============================================================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -