长话短说
目前 能从实验 的现象 稳定再现, 写入EEPROM 几个字节 正常
写入 十几个 字节, EEPROM 写入 正常, 但是中断 就再也不能响应了!!
不知道 是 我程序 问题, 还是 芯片的问题!
大家有没有类似现象?
部分代码
========================================================
/**********************************************************
*
**********************************************************/
#define WR_PG_DIS ( 1 << 0 )
#define HVOFF_BIT ( 1 << 6 )
/**********************************************************
* 奶奶的 资料上说是 EOP 结果 STM8S105 等不到 EOP, 后来看ST库,结果
* 他等的是 HVOFF
*************************************************/
void WaitEOP( void )
{
unsigned char flagstatus;
unsigned short TimeOut;
for( TimeOut = 0; TimeOut < 0xFFFF; TimeOut++ )
{
flagstatus = ( FLASH_IAPSR & ( WR_PG_DIS | HVOFF_BIT ));
if( flagstatus != 0 )
{
break;
}
}
//超时退出
}
/**********************************************************
*
**********************************************************/
void InitWriteEEPROM( void )
{
if( 0 == FLASH_IAPSR_DUL )
{
FLASH_DUKR = 0xAE;
FLASH_DUKR = 0x56;
while( 0 == FLASH_IAPSR_DUL );
}
}
/**********************************************************
* 就是EEPROM 空的时候 执行这个时候,有问题的
*****************************************************/
void LoadDefaultSysPara( void )
{
InitWriteEEPROM();
*(( unsigned char * ) EEPROM_ServicePosition ) = 50;
WaitEOP();
*(( unsigned char * ) EEPROM_BackwashPosition ) = 10;
WaitEOP();
*(( unsigned char * ) EEPROM_BrineDrawPosition ) = 10;
WaitEOP();
*(( unsigned char * ) EEPROM_WashPosition ) = 40;
WaitEOP();
*(( unsigned char * ) EEPROM_ReFillPosition ) = 50;
WaitEOP();
*(( unsigned char * ) EEPROM_SafeDuration ) = 15;
WaitEOP();
*(( unsigned char * ) EEPROM_G_FlowModulusH ) = 6;
WaitEOP();
*(( unsigned char * ) EEPROM_G_FlowModulusL1 ) = 9;
WaitEOP();
*(( unsigned char * ) EEPROM_G_FlowModulusL2 ) = 4;
WaitEOP();
*(( unsigned char * ) EEPROM_G_FlowModulusL3 ) = 4;
WaitEOP();
*(( unsigned char * ) EEPROM_M_FlowModulusH ) = 2;
WaitEOP();
*(( unsigned char * ) EEPROM_M_FlowModulusL1 ) = 6;
WaitEOP();
*(( unsigned char * ) EEPROM_M_FlowModulusL2 ) = 2;
WaitEOP();
*(( unsigned char * ) EEPROM_M_FlowModulusL3 ) = 0;
WaitEOP();
*(( unsigned char * ) EEPROM_Language ) = LangType_English;
WaitEOP();
*(( unsigned char * ) EEPROM_ValveType ) = 1;
WaitEOP();
*(( unsigned char * ) EEPROM_DefaultType ) = 2;
WaitEOP();
} |