This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Problem with using IAR C-SPY System Macros in Simulator

I'm probably missing something simple but in the code sample below, run in the Simulator, the macros don't seem to be being recognised (although I believe they are permanently registered); in the sample below I am trying to store a stream of values in a disk file. The macros,  __openFile() and __writeFile() aren't being recognised. Also, a clue: the "__var" declaration is not recognised and flagged as "undefined".

Ideas ???

int main( void )
{
 
  int test_A,test_B;

  // Stop watchdog timer to prevent time out reset
  WDTCTL = WDTPW + WDTHOLD;

  test_A = 0;
 
  __var fhMyHandle;
  fhMyHandle = __openFile("C:outfile.txt","w");
 
  for (int i=0;i<10;i++)
  {
    test_A +=1;
    test_B = test_A;
      
    __writeFile(fhMyHandle, test_A);
        
  }

  • John Brydon1 said:
    Ideas ???

    Well, it looks liek you're using type and funciton definitions that are unknown at compile time.
    You probably have to include some header file declaring them.
    None of the __xxxx symbols are standard C or common MSP430 symbols. Where did you get the idea you could use them?

    Remember, the MSP has no OS and therefore no file system drivers etc. If you want to use something like that, you'll have to include the proper code, or use a library with the proper code. And include the header definitions.

    Microcontrolelr programming means using only the necessary, not having a full OS in the background for blinking an LED.

  • I got the idea that I could use them because it says I can on p.205 of the IAR EW340 Debugging Guide (one of the user guides referenced in Embedded Workbench). There is a whole chapter on C-Spy Macros. As you imply, I think I need a header file or equivalent but I've scoured the text and there is no reference to one. It's probably something so obvious that it isn't explicitly documented - but I still can't find It !

    J.

  • Ah, I see. I jsu tread part of the chapter.

    Well, the C-Cpy macros need to be registered before they can be used.
    This is done using the Macro Configuration dialog.
    Or by loading a macro file at C-Spy start.

    However, system macros should be already registered.

    Now, i think you misinterpreted their usage.

    The C-Spy macros are not meant to be used in your target source code. They are meant to be control scripts that control the build and debug process itself.

    So teh file operation macros do not add file operation functionality on your MSP program - they are used for file operations such as logging of the build or debug process itself and are executed on the PC.

    In other words: the C-SPY macros control the behavior of compiler/linker/debugger and do not influence the MSP code.

**Attention** This is a public forum