21ic问答首页 - PIC47Q10读写EEPROM,我是用的MCC生成的代码,会有错误吗?
PIC47Q10读写EEPROM,我是用的MCC生成的代码,会有错误吗?
橘子阿小2021-08-05
MCC生成的代码如下:void WR_EEPROM(uint16_t bAdd, uint8_t bData)
{
uint8_t GIEBitValue = INTCONbits.GIE;
NVMADRU = 0x31;
NVMADRH = (uint8_t)((bAdd & 0xFF00) >> 8);
NVMADRL = (uint8_t)(bAdd & 0x00FF);
NVMDATL = (uint8_t)(bData & 0xFF);
NVMCON0bits.NVMEN = 1;
INTCONbits.GIE = 0;
NVMCON2 = 0x55;
NVMCON2 = 0xAA;
NVMCON1bits.WR = 1;
while (NVMCON1bits.WR)
{
}
NVMCON0bits.NVMEN = 0;
INTCONbits.GIE =GIEBitValue;
}
uint8_t RD_EEPROM(uint16_t bAdd)
{
NVMADRU = 0x31;
NVMADRH = (uint8_t)((bAdd & 0xFF00) >> 8);
NVMADRL = (uint8_t)(bAdd & 0x00FF);
NVMCON1bits.RD = 1;
NOP();
NOP();
return (NVMDATL);
}
{
uint8_t GIEBitValue = INTCONbits.GIE;
NVMADRU = 0x31;
NVMADRH = (uint8_t)((bAdd & 0xFF00) >> 8);
NVMADRL = (uint8_t)(bAdd & 0x00FF);
NVMDATL = (uint8_t)(bData & 0xFF);
NVMCON0bits.NVMEN = 1;
INTCONbits.GIE = 0;
NVMCON2 = 0x55;
NVMCON2 = 0xAA;
NVMCON1bits.WR = 1;
while (NVMCON1bits.WR)
{
}
NVMCON0bits.NVMEN = 0;
INTCONbits.GIE =GIEBitValue;
}
uint8_t RD_EEPROM(uint16_t bAdd)
{
NVMADRU = 0x31;
NVMADRH = (uint8_t)((bAdd & 0xFF00) >> 8);
NVMADRL = (uint8_t)(bAdd & 0x00FF);
NVMCON1bits.RD = 1;
NOP();
NOP();
return (NVMDATL);
}
赞0
我还是出现那个问题,请问您知道为什么我的时钟参数修改完,确保存不了吗?
评论
2021-08-06
赞0
谢谢,我试一下
评论
2021-08-06
赞0
评论
2021-08-05
赞0
评论
2021-08-05
您需要登录后才可以回复 登录 | 注册