2014-02-20 4 views
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 확인하려고되면 정지

지우기 및 데이터 쓰기가 작동하는 것처럼 보입니다. 이 문제의 원인은 무엇입니까?

이 코드는 다른 응용 프로그램에서 작동합니다.

답변

0

어떤 메모리 블록을 덮어 씁니까? 거기에 어떤 데이터가 있습니까? 당신이 작성하는 동안 accura 수있는 로더, 또는 일부 인터럽트 처리기에 의해 사용되는 일부 기능을 재정의하지 마십시오?

+0

저는 응용 프로그램에서 새 부트 로더를 작성하고 있습니다. 인터럽트가 비활성화됩니다. –

+0

플래시 메모리가 읽기 위해 잠겨 있지 않은지 확인하십시오. – kirill