HI各位,请教一下有没遇到PIC16F1824内部晶振偏差10%的问题,我配置内部晶振为2M,同时引出CLKOUT引脚,测出它的频率是550K,理论上应该是要2M/4也就是500K,误差10%这也太大了吧,另外有没有遇见eeprom写入数据并回读校验正常,掉电重启一下数据丢失,全是0xFF的情况?
static void eepromWriteByte(unsigned char addr,unsigned char val){
unsigned char gie;
EEADRL = (unsigned char)(addr & 0xFF);
EEDATL = (unsigned char)(val);
EECON1bits.EEPGD = 0;
EECON1bits.CFGS = 0;
EECON1bits.WREN = 1;
gie = INTCONbits.GIE;
INTCONbits.GIE = 0;
EECON2 = 0x55;
EECON2 = 0xAA;
EECON1bits.WR = 1;
while(EECON1bits.WR);
EECON1bits.WREN = 0;
INTCONbits.GIE = gie;
return;
}
static unsigned char eepromReadByte(unsigned char addr){
EEADRL = addr;
EECON1bits.CFGS = 0;
EECON1bits.EEPGD = 0;
EECON1bits.RD = 1;
asm("nop");
asm("nop");
return (EEDATL);
}
|