DASM (05.09.2005 09:08, просмотров: 1) ответил AndrewVer на Да вроде все правильно пишу туда
ну вот рабочий кусок <PRE>
#ifdef FlashRelease
__ramfunc
#endif
#define PAGE_SIZE 32
bool WritePage (int adr, int *pbuf)
{
int *pflash = (int *)adr;
int page = adr >> 7;
int region = (adr >> 12);
if (AT91C_BASE_MC->MC_FSR & (region << 16))
{
// lock set, clear it
AT91C_BASE_MC->MC_FMR = ((AT91C_MC_FMCN)&(50 <<16)) | AT91C_MC_FWS_1FWS ;
AT91C_BASE_MC->MC_FCR = (0x5A << 24) | (region << 8 ) |AT91C_MC_FCMD_UNLOCK;
}
while (!(AT91C_BASE_MC->MC_FSR & AT91C_MC_FRDY))
;
for (int i = 0; i < PAGE_SIZE; i++)
{
*(pflash + i ) = *(pbuf + i);
}
AT91C_BASE_MC->MC_FMR = ((AT91C_MC_FMCN)&(100 <<16)) | AT91C_MC_FWS_1FWS ;
AT91C_BASE_MC->MC_FCR = (0x5A << 24) | (page << 8 ) |AT91C_MC_FCMD_START_PROG;
while (!(AT91C_BASE_MC->MC_FSR & AT91C_MC_FRDY))
;
return true;
}