Now I am using ra6t1 to develop my application, and get a problem when I use flash erase, and I will show my problem with an simple example.
first, I make a new simple project like this.
In this simple project, I just use gpt12, open the gpt12 overflow interrupt, with 1ms cycle.
And the problem is once run the function R_FLASH_HP_Erase(), and the mcu will go out of control, if in the debug mode, it will go here below.
I guess it is about the interrupt problem when the mcu is in flash erase situation. But I don't know the problem exactly, and how to solve this problem, because there will be several interrupts when do the flash programming.
Thanks for reaching out to Engineering Community.
For code flash, BGO ( Background Operation) is not supported, so a code flash operation will not return before the operation has completed. If an…
For code flash, BGO ( Background Operation) is not supported, so a code flash operation will not return before the operation has completed. If an interrupt occurs during the code flash operation, then code flash will be accessed to fetch the interrupt's starting address and an error will occur. The simplest way to overcome this issue is to disable interrupts before entering code flash operations and enabling them again after they have completed.
You can check here the example about flash_hp to see how to do it.
Also, are you absolutely sure that you are not erasing a block your code resides in? You are erasing the block starting at 8kB. This doesn't leave much code space for your application.
Yes, I think so. In my real project, I define a big array on this part of flash. In this project I showed, it is just a small project, I checked the code with debug mode, and run with breakpoint, I confirm that it is caused by the function R_FLASH_HP_Erase(), and at least, this function and the function called it, they are none of business with the flash section I erased.
If you look at the .map file in the Debug folder you will be able to see if anything is allocated to this flash area. If there is any code etc needed by the running application and it is erased then this would cause problems. Can you post the .map file here?
Thanks, this helps.
Thank you for your help. I think I have found the probelm accordding to AZ_Renesas's answer.
I am sorry that I can't upload the map file successful, I don't know why.
But I am interested in how to check if the compiler use some specific area with map file.
Can you show me this with a simple example?