Te sugerimos que revises esta solución en un ambiente controlado antes de enviarlo a producción, saludos.
Ejemplo 1: cómo leer y escribir la memoria flash stm32
//setup memory// Modify Flash Address according to target MCUHAL_FLASH_Unlock();FLASH_Erase_Sector(11, FLASH_VOLTAGE_RANGE_3);HAL_FLASH_Lock();//write to memoryHAL_FLASH_Unlock();uint8_t rdBuf[5];uint8_t wrBuf[5]=0x11,0x22,0x33,0x44,0x55;uint32_t flashAddress =0x080E0000;for(uint32_t i=0; i<5; i++)HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE, flashAddress,((uint8_t*)wrBuf)[i]);
flashAddress++;HAL_FLASH_Lock();//read
flashAddress =0x080E0000;for(uint32_t i=0; i<5; i++)*((uint8_t*)rdBuf + i)=*(uint8_t*)flashAddress;
flashAddress++;
Ejemplo 2: cómo escribir memoria flash en stm32f030
// You can write into flash page but can not over write erase page before write again.//https://stackoverflow.com/questions/47373317/how-to-write-erase-on-chip-flash-continuously-in-stm32f030-familyuint32_t pageAddress =0x08008000;uint16_t buffer =0xdddd;// data buffer
HAL_HAL_StatusTypeDef status;while(1)HAL_FLASH_Unlock();// unlock the flash memory in ST//FLASH_PageErase(pageAddress);
status=HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, pageAddress,
buffer);HAL_FLASH_Lock();// Flash memory locked
Si conservas alguna indecisión o capacidad de ascender nuestro artículo te recomendamos dejar una crónica y con gusto lo interpretaremos.
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)