Hi Alexandre Voigt da Poian
You can check the Reference Manual, in the "Flash Memory Module (FTFA)" you can find a note:
A flash memory location must be in the erased state before
being programmed. Cumulative programming of bits (back-toback
program operations without an intervening erase) within a
flash memory location is not allowed. Re-programming of
existing 0s to 0 is not allowed as this overstresses the device.
It is not necessary to make all the process of the code example, but if you want to program a section, you first need to erase it. as you are trying to program the same section, then this operation is not allowed.
Hope this helps
Best regards
Jorge Alcala