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.

[InstaSPIN and FLASH-API] Illegal Interrupt / ESTOP0

Other Parts Discussed in Thread: CONTROLSUITE, MOTORWARE

Hello dear e2e-community,

I am developing a project based on the F28069M controller and the DRV8301-EvalBoard, and one customer requirement was to write parameter data to non-volatile memory -> flash.

We found this (quite old) guideline on the ti website: http://www.ti.com/lit/an/sprab69/sprab69.pdf

Our MotorWare project is based on lab04, and I started by including the FlashAPI-library from controlSUITE\device_support\f2806x\v150\F2806x_common\lib\2806x_BootROM_API_TABLE_Symbols.lib

Then I had to do some modifications on the EEPROM-emulation code, and in the end, it was working quite well.

Afterwards, we included some minor features of our motor-control project, and then the Flash-commands went wrong. When called the first time, I can write to flash, and I can see in the memory browser that it worked. And by the second call to Flash_Program(..), I always come out in a "ESTOP0" in the Boot-ROM memory region (0x3FF4FA).

Can anybody explain this?

We are using MotorWare 1.01.00.16, we tried CCS 6.1 and 6.1.3

I hope someone can help us - thanks a lot in advance!

Regards,

Philipp

  • Philipp,

    looks like the device is going through a reset. That Address belongs to WAITBOOT. Since you have emulator connected and are able to do source level debug. Can you check if watchdog is disabled, also can you put a HW break point at below

    1.> 0x003ff75b - if the program control hits this break point then device is going through a reset. Now we need to find why.

    2.> 0x003ff781 - if the program control hits this break point then device got into ITRAP handler in ROM (do you have PIE disabled)?

    if the device goes through a reset without hitting iTRAP in ROM or other exceptions in application if you have PIE enabled in your code then it must be watchdog. 

    Also please check the code modifications that were added, you might want to incrementally add the modifications to see which one is causing the failure.

    Hope this helps.

    Best Regards

    Santosh Athuru

  • Dear Santosh,

    Thank you very much for your answer.

    My program hits both breakpoints you mentioned.

    Perhaps I should explain some more: We are using a totally standard InstaSPIN-Lab (Lab04), and I have added support for the Flash-API.

    Our program looks (roughly) like this:

    void main(void)
    {
       // Standard InstaSPIN init's
       // ... 
       halHandle = HAL_init(&hal,sizeof(hal));
       // ...
       USER_setParams(&gUserParams);
       // ...
       HAL_setParams(halHandle,&gUserParams);
       
       // >> My custom FLASH_API_init
       retval = FLASH_API_init();
    
       // >>> HERE: FIRST WRITE TO FLASH
    
       // ... lots of standard InstaSPIN-Stuff
       for(;;)
       {
          // ...
          while(gMotorVars.Flag_enableSys)
          {
             // .... more standard stuff
    
             // >>> HERE: SECOND WRITE TO FLASH
    
             // .... more standard stuff
          }
    
       } // end of for(;;) loop
    
    } // end of main() function
    
    
    interrupt void mainISR(void)
    {
       // no real changes here
       // ... lots of standard InstaSPIN-Stuff
    }

    When I write to flash at the first position (comment "First write to flash"), there are no problems. I can even put a loop there, and write a whole sector of flash, using my modified EEPROM-Emulation library, which basically calls "Flash_Program(..)" from the Flash-API.

    But when I try to write just a single Word of Flash in the second position (comment "second write to flash"), the problems from my first post come through.

    So my question is: What is the difference between those two positions in the program? What happens in a standard InstaSPIN-Lab at the first, and/or at the second position? I think the watchdog is generally disabled in the InstaSPIN-Labs. (There is not even a HAL-Function to enable it ..)

    When we write to flash, it is at a absolutely non-critical point in our program. The motor is not running, we are in "idle-mode". So we have lots of time, we already have disabled all interrupts with the "DINT"-instruction - what else can we do to create an environment where the Flash-commands are not disturbed?

    Because this is what is happening, I guess - I have single stepped for a while, and this ITRAP seems to happen while the program is in the "Flash-Program"-function (which is sadly a black box for me, I just added the library to my project).

    I am looking forward to your answer, I hope we can clear this up together!

    Regards,

    Philipp

    EDIT:

    I forgot to mention, this is what happens in my Flash-API-Init. My Flash-Write-Function basically just calls "Flash_Program()"

    #define ADRESS_FLASH_CPU_SCALE_FACTOR	0x000D04
    #define FLASH_CPU_SCALE_FACTOR  (*((volatile uint32_t *)(ADRESS_FLASH_CPU_SCALE_FACTOR)))
    
    #define ADRESS_FLASH_CALLBACK_PTR	0x000D02
    #define FLASH_CALLBACK_PTR  (*((volatile uint32_t *)(ADRESS_FLASH_CALLBACK_PTR)))
    
    int16_t FLASH_API_init()
    {
    	int16_t retval = -1;
    
    	mypll = PLLCR_REGISTER;
    
    	if (mypll != 18)	// 18 means: 90 MHz CPU Clock - change this value for other Clockrate!
    	{
    	  // SCALE_FACTOR is calculated from CPU_RATE, which is specified
    	  // in Flash2806x_API_Config.h only for 90 MHz
    	  retval = -2;		// ERROR!
    	}
    	else
    	{
    	  EALLOW;
    	  FLASH_CPU_SCALE_FACTOR = SCALE_FACTOR;
    	  FLASH_CALLBACK_PTR = (uint32_t)&MyCallbackFunction;
    	  EDIS;
    	  MyCallbackCounter = 0; // Increment this counter in the callback function
    
    	  if(Flash_APIVersionHex() != 0x0100)
    		  retval = -3;
    	  else
    		  retval = 0;
    	}
    
    	// check for completely empty flash
    	checkEmpty = *((Uint16 *)0x3DC000);
    	if (checkEmpty == 0xFFFF)
    	{
    		retval = 1;		// flash is empty
    	}
    
    
    	return retval;
    }

  • So the CPU is fetching an illegal instruction sometime during the second call to write flash. To be sure you are not erasing the sectors/locations that you are running from. I believe you should be running from RAM at this point and the callback function assigned to flash API during Flash INIT is in RAM as well?

    Also can you confirm if you are linking the Flash API in ROM?

    I'll ask the Flash API expert to look into this thread as well.

    Best Regards

    Santosh Athuru

  • Flash API library functions needs to be run from RAM. Based on the message thread, I believe you are doing that already.

    Did you check whether the stack is getting corrupted? If you carefully single step through the code, you should be able isolate the instruction which is causing this issue?

    Just to eliminate the remote possibility of defective device (trying to avoid corrupted ROM code / stuck at faults in RAM), try running the code from another device. If you see the same problem, then it should be software issue.


    Regards,

    Manoj

  • Hello Manoj and Santosh,

    Thank you for your answers.

    How can I confirm if I am linking the Flash API in ROM?

    I will check for "running from RAM" tomorrow, but I think I did it correctly. And when executed from the first location, everything works fine...

    I will see tomorrow if I can isolate the exact instruction which causes the problem, and I will try another ControlCard to be sure.

    Can it perhaps also be a power supply problem? I am currently supplying the ControlCard via its micro-USB port.

    ... And I can't stop wondering why it works perfectly at the first location in code, but not at all at the second location .. what is getting changed in the meantime?

    Regards,

    Philipp

  • {Philip,
    between first and second writes, the locations that you are writing to in flash are same or different? are the locations erased before you program.

    When you single step a flash API, if it is going to ROM address range then you are linking the flash API in ROM. I believe this would be a quick check, Manoj might have other ways to find out from library name or version. What is the name of the Flash API lib you are linking to?

    Best Rrgards
    Santosh Athuru
  • I would recommend you try the suggestions mentioned in this link
    processors.wiki.ti.com/.../Interrupt_FAQ_for_C2000
  • Hello Manoj and Santosh,

    Thank you again for your help, but I think we fixed it, and the problem was something different.

    In our program, we have certain points where we must re-initialize the whole hardware (the HAL in InstaSPIN), because we have to change the PWM frequency when the user requensts it. In this HAL-init, also the Flash is being re-initialized, but the problem was, that we did not re-initialize our Flash-API.

    After adding the Flash-API-reinitialization, everything seems to work like a charm!

    So again, thanks for your help! 

    Regards,

    Philipp