Hi Danilo,
I run your code on my side, it works ok:

I think your problem is caused by the 0X1F000 didn't do flash erase before, and 0X1F000 already have data.
To the flash, when you want to write the data, you should make sure that area is erased, so normally, customer need to do the sector erase before do the flash write.
You can do a sector erase before :
Error = FLASH1_Write(MyFLASH_Ptr, Data, MY_FLASH_LOCATION, sizeof(Data)); //Start writing to the flash memory
Your code can work on my side, because I do the mass erase before download the data, so the 0X1F000 is 0xff on my side before do flash write operation.
Wish it helps you!
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------