Closed Amomum closed 7 years ago
Hello! -- I think that SystemInit()
and some other procedures involved into MCU startup should be considered just as examples or templates that the developer will adapt to a particular project. This is a non-trivial task -- to write a startup code which will fit to every project.
Hmm. I think that the best way to use a library is to include it 'as is', as submodule or a subtree or whatever. Then it can be updated with minimal effort.
I consider rewriting parts of the library after cloning absolutely unacceptable, using some files as templates is possible (although it will make updating them more difficult) but those files should be clearly marked as templates.
I suppose the best (or least worst) thing is to provide something close to absolutely necessary minimum SystemInit. And I think current version is pretty close to that. Maybe modifying VTOR can be removed altogether?
I absolutely agree that the current structure of the library is far from ideal. As I see it, one of the goals of this particular library is to keep the full compatibility with the original. However, nothing hinders someone from refactoring of the library and creating another better organized one))
As for VTOR
, let's wait for an answer of @eldarkg
@Amomum I think you should rename definition to MDR_NO_RST_VTOR. Can you open a pull request? P.S. I'll merge it because this VTOR reset breaks the Keil simulator work (as say @Amomum).
In file CMSIS/CM3/DeviceSupport/MDR32F9Qx/startup/system_MDR32F9Qx.c at line 144:
Which can be seen as necessary as per datasheet:
But I can see with my debugger that just after reset startup code from ROM (from address 0) executes and sets VTOR to 0x08000000. So modifying VTOR programmatically is unnecessary. But we should not rely on this behaviour since it's not even mentioned anywhere in datashet (as far as I know).
Setting VTOR programmatically to this value in SystemInit may be undesirable in two cases:
I propose to do something like this:
so the end-user can disable this feature without modifying this code or manually resetting VTOR again in his main-code.