Hello,
I’m having trouble using the HAL_FLASH_Program, every time it throws a hard fault error. Even when I’ve checked the memory I’m accessing and the page size.
The code is
#include <mbed.h>
#include “stm32l4xx_hal.h”
#define page249addr 0x807C800
void save(uint32_t data, uint32_t address)
{
HAL_FLASH_Unlock();
HAL_FLASH_OB_Unlock();
HAL_StatusTypeDef statusprogram;
statusprogram = HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD,address,data);
uint32_t error = HAL_FLASH_GetError();
if (statusprogram != HAL_OK){
printf(“Error %lu\n”,error);
}
HAL_FLASH_OB_Lock();
HAL_FLASH_Lock();
}
int main() {
// put your setup code here, to run once:
HAL_Init();
save(30.8,page249addr);
while(1) {
// put your main code here, to run repeatedly:
}
}
It would be great if someone can point out what I’m doing wrong?
Thank you in advance