Initializing target hardware before C-SPY starts
You can use C-SPY macros to initialize target hardware before C-SPY starts. For example, if your hardware uses external memory that must be enabled before code can be downloaded to it, C-SPY needs a macro to perform this action before your application can be downloaded.
Create a new text file and define your macro function.
By using the built-in
execUserPreloadsetup macro function, your macro function will be executed directly after the communication with the target system is established but before C-SPY downloads your application.For example, a macro that enables external SDRAM could look like this:
/* Your macro function. */ enableExternalSDRAM() { __message "Enabling external SDRAM\n"; __writeMemory32(...); } /* Setup macro determines time of execution. */ execUserPreload() { enableExternalSDRAM(); }Save the file with the filename extension
mac.Before you start C-SPY, choose Project>Options>Debugger and click the Setup tab.
Select the Use macro file option, and choose the macro file you just created.
Your setup macro will now be loaded during the C-SPY startup sequence.