diff --git a/targets/TARGET_STM/TARGET_STM32L4/flash_api.c b/targets/TARGET_STM/TARGET_STM32L4/flash_api.c index 534894f08a..826e15e696 100644 --- a/targets/TARGET_STM/TARGET_STM32L4/flash_api.c +++ b/targets/TARGET_STM/TARGET_STM32L4/flash_api.c @@ -205,7 +205,7 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, /* HW needs an aligned address to program flash, which data * parameters doesn't ensure */ - if ((uint32_t) data % 4 != 0) { + if ((uint32_t) data % 8 != 0) { volatile uint64_t data64; while ((address < (StartAddress + size)) && (status == 0)) { for (uint8_t i = 0; i < 8; i++) { diff --git a/targets/TARGET_STM/TARGET_STM32WB/flash_api.c b/targets/TARGET_STM/TARGET_STM32WB/flash_api.c index 3be8ad9248..8e708724d8 100644 --- a/targets/TARGET_STM/TARGET_STM32WB/flash_api.c +++ b/targets/TARGET_STM/TARGET_STM32WB/flash_api.c @@ -154,7 +154,7 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data, StartAddress = address; /* HW needs an aligned address to program flash, which data parameters doesn't ensure */ - if ((uint32_t) data % 4 != 0) { // Data is not aligned, copy data in a temp buffer before programming it + if ((uint32_t) data % 8 != 0) { // Data is not aligned, copy data in a temp buffer before programming it volatile uint64_t data64; while ((address < (StartAddress + size)) && (status == 0)) { for (uint8_t i = 0; i < 8; i++) {