0
PIC32MX360F512L에서 내부 플래시 블록을 프로그래밍하고 확인하려고합니다. 한 번에 4096 바이트 블록을 지우고, 프로그램하고 확인하는 기능이 있습니다. 그것을 실행할 때 함수는 첫 번째 바이트를 확인하는 동안 중단됩니다.소프트웨어를 통한 Progam PIC32 내부 플래시
경우 (* ((부호 INT *) PA_TO_KVA1 (CurrentAddress)) = * pData의)
:BOOL Loader_ProgramFlashBlock(unsigned long int adr, unsigned int *p)
{
unsigned long int CurrentAddress;
unsigned long int PageEndAddress;
unsigned int *pData;
unsigned int nvmResult;
// Calculate the beginning and ending addresses of the page.
CurrentAddress = adr;
PageEndAddress = CurrentAddress + FLASH_BLOCK_SIZE;
pData = (unsigned int *)p;
// Check to see if the page has been erased
{
// If not, erase the page & log track it
nvmResult = NVMErasePage((void *)CurrentAddress);
if (nvmResult != 0)
{
// Error erasing Flash page
return FALSE;
}
}
// Program the block to Flash
while (CurrentAddress < PageEndAddress)
{
if (NVMWriteWord((void *)CurrentAddress, *pData) != FALSE)
{
// Error Writing Flash
return FALSE;
}
pData++;
CurrentAddress += sizeof(unsigned int);
}
// Verify that the block was written correctly
// (This check will identify writes to a Flash block that was not fully erased.)
CurrentAddress = adr;
pData = (unsigned int *)p;
while (CurrentAddress < PageEndAddress)
{
// Compare buffer contents to Flash contents
if (*((unsigned int *)PA_TO_KVA1(CurrentAddress)) != *pData)
{
// Flash and buffer did not match.
return FALSE;
}
pData++;
CurrentAddress += sizeof(unsigned int);
}
return TRUE;
} // Loader_ProgramFlashBlock
함수는 광고에서 플래시의 제 WORD 확인하려고되면 정지
지우기 및 데이터 쓰기가 작동하는 것처럼 보입니다. 이 문제의 원인은 무엇입니까?
이 코드는 다른 응용 프로그램에서 작동합니다.
저는 응용 프로그램에서 새 부트 로더를 작성하고 있습니다. 인터럽트가 비활성화됩니다. –
플래시 메모리가 읽기 위해 잠겨 있지 않은지 확인하십시오. – kirill