Цитата(swagger @ Mar 13 2014, 07:06)

Добрый день!
Изучаю PIC32 на отладочной плате UNO32 компилятор С32. Вопрос по сохранению данных пользователя при сбросе питания. EEPROM нет как в PIC18. Получается сохраняем во flash память?
ага, именно так.
Вот кусок из моего старенького, опирается на NVN "Microchip PIC32MX Peripheral Library"
CODE
/***********************************************************************
PROCEDURE: SerMem_reading
This procedure reads multiple addresses of the device and stores
data into RAM buffer
Input:
startAddr: Destination Address 000000H - 3FFFFFH
no_bytes Number of bytes to read
*pntres - the pointer of the read data
Returns:
Nothing
/************************************************************************/
void SerMem_reading(u32 startAddr, u8 *pntres, u16 no_bytes )
{
u8 *pnt = (u8*)startAddr;
while (no_bytes > 0)
{
*pntres = *pnt; /* receive byte and store at address 80H - FFH */
pntres++;
*pnt++;
no_bytes--;
}
return;
}
/***********************************************************************
PROCEDURE: SerMem_writing
This procedure writes multiple addresses of the device
Input:
startAddr: Destination Address aligned 4
nbytes Number of bytes (4,8,12,16....)
*pntres - the pointer in RAM of the data
Returns:
Nothing
Note:
The smallest block of data that can be programmed in a single operation is 1 instruction word (4 Bytes).
/************************************************************************/
void SerMem_writing(u32 startAddr, u8 *pntres, u16 nbytes)
{
u32 wrdata;
nbytes &=0xFFF4; // align is 4 bytes
while (nbytes > 0)
{
wrdata = *((u32*)pntres);
NVMWriteWord((void*) startAddr, wrdata);
pntres+=4;
nbytes-=4;
startAddr+=4;
}
}
void SerMem_erase4K(u32 startAddr)
{
NVMErasePage((void*)startAddr);
}