Forum Discussion
Hi,
I am sorry for the delayed response. I have been out of the office for the last few days.
Thanks for the link, I tried the #pragma directive to disable GCC optimization for one or more functions and it works.
With this technique I was able to isolate the source of the problem: the function that causes it is flash_read_flag_status_register.
It is implemented in this way:
and is used to check if the write operation is finished and then checks for errors:
// check for errors
do {
flag_status = flash_read_flag_status_register(st);
} while (!(flag_status & FLASH_FSR_READY));
flash_clear_flag_status_register(st);
if (flag_status & FLASH_FSR_PROTECTION_ERR)
{
ret_flag = FLASH_SECTOR_PROTECTED;
break;
}
if ((flag_status & FLASH_FSR_ERASE_ERR) || (flag_status & FLASH_FSR_PROGRAM_ERR))
{
ret_flag = FLASH_ERROR;
break;
}
To avoid using #pragma I tried setting the flag_status variable as volatile, but it doesn't work.
Do you know why if I use volatile for flag_status it doesn't work?
Can you suggest other attentions I can have to avoid other problems with GCC optimization?
Thanks.
Best Regards,
naand