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.

Add datalog in instaSPIN project

Other Parts Discussed in Thread: MOTORWARE

Hello,

I'm trying to add DLOG module into an instaSPIN project but it seems that there is an overlap on the memory.

e.g. : the gMotorVars stucture is filled in with strange values. After that, I restarted the MCU, I tried again and I received the message :

C28xx: Trouble Reading PC Register: (Error -1142 @ 0x0) Device blocked debug access because it is currently executing non-debuggable code. Choose 'Rude Retry' to disable polite mode and force the operation. (Emulation package 5.1.73.0)

 

Here is what I made:

1) I added in my project dlog4ch.c from MotorWare_1_01_00_09

2) I added in my project dlog4ch.asm from MotorWare_1_01_00_09

3) I added in the global vars DLOG_4CH dlog1;

4) I initialized it DLOG_4CH dlog1 = DLOG_4CH_DEFAULTS;

5) In the main for loop, I filled in the dlog structure like this

            dlog1.iptr1 = &DlogCh1;

            dlog1.iptr2 = &DlogCh2;

            dlog1.iptr3 = &DlogCh3;

            dlog1.iptr4 = &DlogCh4;

            dlog1.trig_value = 0x0;

            dlog1.size = 0x400;

            dlog1.prescalar = 1;

            dlog1.init(dlog1);

6) In the main ISR, I updated DLOG with the variables I wanted to log

            DlogCh1 = _IQtoQ15(gMotorVars.SpeedRef_krpm);

            DlogCh2 = _IQtoQ15(gMotorVars.Is_A);

            DlogCh3 = _IQtoQ15(gMotorVars.Torque_Nm);

            DlogCh4 = HallPosition;

            dlog1.update(&dlog1);

7) I modified my RAM linker command file like this :

            MEMORY

           {

           PAGE 0 :

                      RAML0_L3    : origin = 0x008000, length = 0x001800  /* length 0x001800 instead of 0x002000 */

            PAGE 1 :

                      dataRAM    : origin = 0x009800, length = 0x000800   /* dataRAM is in RAML3 for DLOG */

            SECTIONS

           {

                   .ebss            : > dataRAM,    PAGE = 1

                   .econst          : > dataRAM,    PAGE = 1

           

          SECTIONS

          {

                     DLOG: > dataRAM,PAGE=1

          }

8) When I built the project, 0 error and 0 warning

9) I entered in debug mode and clicked on the Resume icon to start the debug.

What did I make wrong?

 

  • you don't necessarily have to use the dlog function.

    You can just create a memory buffer. That is what we did for the graph plots in the InstaSPIN-FOC and -MOTION GUI.

    Ex. In your main.h

    #define DATA_BUFFER_SIZE 200
    _iq SpeedRef_krpm_Buffer[DATA_BUFFER_SIZE];

    in you main.c

    // likely in your main interrupt to get a value each time through the ISR

    Gui.SpeedRef_krpm_Buffer[Gui.gRecordBuffersIndex] = _IQmpy(CTRL_getSpd_int_ref_pu(ctrlHandle), Speed_krpm_sf);

    Gui.gRecordBuffersIndex++;

    //

    we actually expanded this since we had so many variables we were buffering and added in this logic at the end of the mainISR to only capture data every ~1000 ISR cycles.

     Gui.gRecordBuffersIsrCnt++;

      if(Gui.gRecordBuffersIsrCnt >= 1000)
        {
          Gui.gRecordBuffersIsrCnt = 0;
          if(Gui.gRecordBuffers)
            {
              if(Gui.gRecordBuffersIndex < DATA_BUFFER_SIZE)
                {
                  Gui.SpeedRef_krpm_Buffer[Gui.gRecordBuffersIndex] = _IQmpy(CTRL_getSpd_int_ref_pu(ctrlHandle), Speed_krpm_sf);
         Gui.SpeedEst_krpm_Buffer[Gui.gRecordBuffersIndex] = EST_getSpeed_krpm(obj->estHandle);
         //add more variable buffers here
     
                  Gui.gRecordBuffersIndex++;
                }
              else
                {
                  Gui.gRecordBuffers = TRUE;
                  Gui.gRecordBuffersIndex = 0;
                }
            }
          else
            {
              Gui.gRecordBuffersIndex = 0;
            }
        }