Skip to main content

IAR Embedded Workbench for RL78 5.20

Initializing target hardware before C-SPY starts

In this section:

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.

  1. Create a new text file and define your macro function.

    By using the built-in execUserPreload setup 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();
    }
  2. Save the file with the filename extension mac.

  3. Before you start C-SPY, choose Project>Options>Debugger and click the Setup tab.

  4. 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.