芯片型号:PIC16F15345
使用MCC产生的函数读出的数据不对,和用PICkit3读出的数据差很多。求大神指教,怎么解?
MCC读函数如下,读程序存储区都是正常的,读DIA不对:
uint16_t FLASH_ReadWord(uint16_t flashAddr)
{
uint8_t GIEBitValue = INTCONbits.GIE; // Save interrupt enable
INTCONbits.GIE = 0; // Disable interrupts
NVMADRL = (flashAddr & 0x00FF);
NVMADRH = ((flashAddr & 0xFF00) >> 8);
NVMCON1bits.NVMREGS = 0; // Deselect Configuration space
NVMCON1bits.RD = 1; // Initiate Read
NOP();
NOP();
INTCONbits.GIE = GIEBitValue; // Restore interrupt enable
return ((uint16_t)((NVMDATH << 8) | NVMDATL));
} |