上面是主要警告
SSP部分程序还是之前看到的一个帖子的帖主写的,
//#include <SH79F161A.H>
#include "intrins.h"
#include "sh79f166a.h"
void Ssp_Write(unsigned int addr,unsigned char dat);
void Ssp_Erase(unsigned int addr);
unsigned char Read_Flash(unsigned int addr);
unsigned char Ssp_Flag;
void Ssp_Write(unsigned int addr,unsigned char dat)
{
CY=EA;
EA=0;
IB_DATA = dat;
IB_OFFSET = addr&0xff;
XPAGE = ((addr>>8) & 7);
FLASHCON=1;
if(Ssp_Flag!=0x5A)
{
IB_CON2=0;
goto Write_Err;
}
IB_CON1 = 0x6E;
IB_CON2 = 0x05;
IB_CON3 = 0x0A;
IB_CON4 = 0x09;
IB_CON5 = 0x06;
_nop_();
_nop_();
_nop_();
_nop_();
Write_Err:
Ssp_Flag=0;
FLASHCON=0;
XPAGE=0;
EA = CY;
}
void Ssp_Erase(unsigned int addr)
{
CY=EA;
EA=0;
XPAGE = (addr>>8) & 0x07;
FLASHCON=1;
if(Ssp_Flag!=0xA5)
{
IB_CON2=0;
goto Erase_Err;
}
IB_CON1 = 0xE6;
IB_CON2 = 0x05;
IB_CON3 = 0x0A;
IB_CON4 = 0x09;
IB_CON5 = 0x06;
_nop_();
_nop_();
_nop_();
Erase_Err:
Ssp_Flag=0;
FLASHCON=0;
XPAGE=0;
EA = CY;
}
unsigned char Read_Flash(unsigned int addr)
{
unsigned char temp;
FLASHCON=1;
temp=*(unsigned char code *)(addr);
FLASHCON=0;
return(temp);
}
我本人调用语句在
但是发现最后的结果不对,是不是和相关的设置有关,这个掉电存储的问题纠结了很久,大家指正一下吧~
|