EEPROM write snippet
HAL_StatusTypeDef writeEEPROMByte(uint32_t address, uint8_t data)
{
HAL_StatusTypeDef status;
address = address + 0x08080000;
HAL_FLASHEx_DATAEEPROM_Unlock();
status = HAL_FLASHEx_DATAEEPROM_Program(TYPEPROGRAMDATA_BYTE, address, data);
HAL_FLASHEx_DATAEEPROM_Lock();
return status;
}
The above snippet leads to hard-fault handler after HAL_FLASHEx_DATAEEPROM_Program
api.
Source code: mbed import mbed-os-example-lorawan
I edited main.cpp and add below lines before calling the lorawan initialization function,
EEPROM write call from main.cpp
HAL_StatusTypeDef writeEEPROMByte(uint32_t address, uint8_t data)
{
HAL_StatusTypeDef status;
address = address + 0x08080000;
HAL_FLASHEx_DATAEEPROM_Unlock();
status = HAL_FLASHEx_DATAEEPROM_Program(TYPEPROGRAMDATA_BYTE, address, data);
HAL_FLASHEx_DATAEEPROM_Lock();
return status;
}
int main (void)
{
writeEEPROMByte(0, 0x05);
/*followed by lorawan apis*/
}
When I compiled and flashed the binary to the MCU, it entered in hard-fault handler.
hard-fault handler line
*(__IO uint8_t *)Address = (uint8_t) Data;
How do I resolve the hard-fault problem?
Note: EEPROM is working good with I-CUBE-LRWAN firmware (I mean without MBED OS). I don't see any problem with the snippet.
EEPROM write snippet
The above snippet leads to hard-fault handler after
HAL_FLASHEx_DATAEEPROM_Program
api.Source code:
mbed import mbed-os-example-lorawan
I edited main.cpp and add below lines before calling the lorawan initialization function,
EEPROM write call from main.cpp
When I compiled and flashed the binary to the MCU, it entered in hard-fault handler.
hard-fault handler line
How do I resolve the hard-fault problem?
Note: EEPROM is working good with I-CUBE-LRWAN firmware (I mean without MBED OS). I don't see any problem with the snippet.