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.

BOOSTXL-DRV8323RH: universal_motorcontrol_lab : jump to Interrupt_illegalOperationHandler

Part Number: BOOSTXL-DRV8323RH


Hi,

if my codes run inside runMotor1Control routine, it's perfectly work e.g. set obj->flagEnableRunAndIdentify = false ... 

void runMotor1Control(MOTOR_Handle handle)
{
   MOTOR_Vars_t *obj = (MOTOR_Vars_t *)handle;
   MOTOR_SetVars_t *objSets = (MOTOR_SetVars_t *)(obj->motorSetsHandle);
   USER_Params *objUser = (USER_Params *)(obj->userParamsHandle);
   .
   .
   .
   if (objSets->command_MotorIdentify)
   {
      obj->flagEnableRunAndIdentify = false;
      obj->flagRunIdentAndOnLine = false;
      obj->speedRef_Hz = 0;
      obj->flagEnableMotorIdentify = true;

      objUser->motor_Rs_Ohm = 0.001f;
   }
   return;
}   

but when I create subroutine to handle it, it's jump to Interrupt_illegalOperationHandler

void doCommandMotorIdentify(MOTOR_Handle handle)
{
   MOTOR_Vars_t *obj = (MOTOR_Vars_t *)handle;
   MOTOR_SetVars_t *objSets = (MOTOR_SetVars_t *)(obj->motorSetsHandle);
   USER_Params *objUser = (USER_Params *)(obj->userParamsHandle);

   doCommandMotorIdentify(handle);
   
   return;
}

void doCommandMotorIdentify(MOTOR_Handle handle)
{
   MOTOR_Vars_t *obj = (MOTOR_Vars_t *)handle;
   MOTOR_SetVars_t *objSets = (MOTOR_SetVars_t *)(obj->motorSetsHandle);
   USER_Params *objUser = (USER_Params *)(obj->userParamsHandle);

   if (objSets->command_MotorIdentify)
   {
      obj->flagEnableRunAndIdentify = false;
      obj->flagRunIdentAndOnLine = false;
      obj->speedRef_Hz = 0;
      obj->flagEnableMotorIdentify = true;

      objUser->motor_Rs_Ohm = 0.001f;
   }
   return;
}

inside the doCommandMotorIdentify() routine, the statement 

objUser->motor_Rs_Ohm = 0.001f was definitely caused fault :(

also this statement 

if (objSets->command_MotorIdentify == true) will cause fault 

but this statement worked 

if (objSets->command_MotorIdentify) 

can anyone help to explain what's caused this  ?

Danny

  • Hello Danny,

    I've got a quick clarifying question.

    In your second code snippet, is doCommandMotorIdentify() supposed to be calling doCommandMotorIdentify() ? I'm going to assume that it's meant to be runMotor1Control() calling your function instead.

    For the fault, that's interesting. I'd definitely first recommend looking through the C28x Interrupt FAQ - ITRAP Interrupt section, which details some initial debug steps. It can be difficult to debug these kinds of things in isolation without more knowledge of the full system. Additionally, other related posts can be useful to find common causes for an ITRAP- this e2e search should be helpful for you.

    You'll note that ITRAP issues are often associated with stack overflow, incorrectly configured flash, and memory allocation issues.

    Please let me know if any of this is helpful, and if it isn't, I'll continue trying to assist!

    Regards,
    Jason Osborn

    (By the way, as an aside, make sure that doCommandMotorIdentify() is in the motor1_drive.c file with the runMotor1Control() function. I don't think this is the issue based on the symptoms, but it's definitely important.)

  • Hi Jason,

    sorry it's my typo, the second snippet wasn't there, and just call doCommandMotorIdentify() once.

    void runMotor1Control(MOTOR_Handle handle)
    {
        MOTOR_Vars_t *obj = (MOTOR_Vars_t *)handle;
        MOTOR_SetVars_t *objSets = (MOTOR_SetVars_t *)(obj->motorSetsHandle);
        USER_Params *objUser = (USER_Params *)(obj->userParamsHandle);
    
        doCommandMotorIdentify(handle);
        .
        .
        .
        return;
    }

    yes, both doCommandMotorIdentify() and runMotor1Control() are in motor1_drive.c file.

    see below the doCommandMotorIdentify(), I have put some basic statements there without logic or calculations, after some tries, I have discovered if randomly remove just one line / assignment, program can run without interrupted.

    therefore it's memory issues right ? 

    void doCommandMotorIdentify(MOTOR_Handle handle)
    {
        MOTOR_Vars_t *obj = (MOTOR_Vars_t *)handle;
        MOTOR_SetVars_t *objSets = (MOTOR_SetVars_t *)(obj->motorSetsHandle);
        USER_Params *objUser = (USER_Params *)(obj->userParamsHandle);
    
        objUser->motor_Rs_Ohm = 0.001f;
        obj->flagEnableRunAndIdentify = false;
    	obj->flagRunIdentAndOnLine = false;
    	obj->speedRef_Hz = 0;
    	obj->flagEnableMotorIdentify = true;
        objUser->motor_Ls_d_H = 0.001f;
    	objUser->motor_Ls_q_H = 0.001f;
    	objUser->Rr_min_Ohm = (float32_t)0.0f;
    	objUser->Rr_max_Ohm = (float32_t)1000.0f;
    
    
    	return;
    }

    herewith my f28002x_flash_lib_is.cmd

    MEMORY
    {
    
        RAMM0S                    : origin = 0x000128, length = 0x000158
        RAMM1D                    : origin = 0x000280, length = 0x000578
        RAMLS4                    : origin = 0x00A000, length = 0x000800
        RAMLS567                  : origin = 0x00A800, length = 0x001800 /* end address 0x00C000 6k in size */
        RAMGS0                    : origin = 0x00C000, length = 0x0007F8
        CANMRAM					  : origin = 0x049000, length = 0x0007F8
        FLASHBANK0_BOOT           : origin = 0x080000, length = 0x001000
        FLASHBANK0_CODE           : origin = 0x081000, length = 0x00C000
        FLASHBANK0_DATA           : origin = 0x08D000, length = 0x001000
    	FLASHBANK0_VAR  		  : origin = 0x08E000, length = 0x001000
        FLASHBANK0_PRMS           : origin = 0x08F000, length = 0x000FF0
        RESET                     : origin = 0x3FFFC0, length = 0x000002
    }
    
    /* .ebss = global variable; cinit = initial value; .stack = local variable; .text = code*/
    SECTIONS
    {
    
        .reset               : >  RESET, TYPE = DSECT /* not used, */
        codestart            : >  0x080000
        .text                : >  FLASHBANK0_CODE,
                                  ALIGN(8)
    
       GROUP
       {
        .TI.ramfunc
         ramfuncs
        }
        						  LOAD >  FLASHBANK0_CODE,
                                  RUN  >  RAMLS567,
                                  LOAD_START(RamfuncsLoadStart),
                                  LOAD_END(RamfuncsLoadEnd),
                                  LOAD_SIZE(RamfuncsLoadSize),
                                  RUN_START(RamfuncsRunStart),
                                  RUN_END(RamfuncsRunEnd),
                                  RUN_SIZE(RamfuncsRunSize),
                                  ALIGN(8)
    
        ctrlfuncs            :    LOAD >  FLASHBANK0_CODE,
                                  RUN  >  RAMLS567,
                                  LOAD_START(loadStart_ctrlfuncs),
                                  LOAD_END(loadEnd_ctrlfuncs),
                                  LOAD_SIZE(loadSize_ctrlfuncs),
                                  RUN_START(runStart_ctrlfuncs),
                                  RUN_END(runEnd_ctrlfuncs),
                                  RUN_SIZE(runSize_ctrlfuncs),
                                  ALIGN(8)
    
        .binit                : >  FLASHBANK0_DATA,
                                  ALIGN(8)
        .cinit                : >  FLASHBANK0_DATA,
                                  ALIGN(8)
        .stack                : >  RAMM0S
        .init_array           : >  FLASHBANK0_CODE,
                                  ALIGN(8)
        .bss                  : >  RAMM1D
        .const                : >  FLASHBANK0_CODE,
                                  ALIGN(8)
        .data                 : >  RAMM1D
        .switch               : >  FLASHBANK0_CODE,
                                  ALIGN(8)
        .sysmem               : >  RAMM1D
    
        est_data             : >  RAMLS4,
                                  LOAD_START(loadStart_est_data),
                                  LOAD_END(loadEnd_est_data),
                                  LOAD_SIZE(loadSize_est_data)
    
        hal_data             : >  RAMM1D,
                                  LOAD_START(loadStart_hal_data),
                                  LOAD_END(loadEnd_hal_data),
                                  LOAD_SIZE(loadSize_hal_data)
    
        user_data            : >  RAMM1D,
                                  LOAD_START(loadStart_user_data),
                                  LOAD_END(loadEnd_user_data),
                                  LOAD_SIZE(loadSize_user_data)
    
        foc_data             : >  RAMM1D,
                                  LOAD_START(loadStart_foc_data),
                                  LOAD_END(loadEnd_foc_data),
                                  LOAD_SIZE(loadSize_foc_data)
    
        sys_data             : >  RAMM1D,
                                  LOAD_START(loadStart_sys_data),
                                  LOAD_END(loadEnd_sys_data),
                                  LOAD_SIZE(loadSize_sys_data)
    
    	ble_data             : >  RAMGS0,
                                  LOAD_START(loadStart_ble_data),
                                  LOAD_END(loadEnd_ble_data),
                                  LOAD_SIZE(loadSize_ble_data)
    
       DataBufferSection : > RAMGS0, ALIGN(8)
    .DevOpt_Array (NOLOAD) : {} > 0x08E000, ALIGN(8)
    }
    

    and memory allocation 

    can you help to take a look ? 

    Danny

  • Danny,

    My instinct here, looking at what you've provided so far, is initially just to increase the size of the stack allocation.{Ignore this, see below} In order to test if this would help, run your program with a breakpoint at the beginning of your custom function. There, you should be able to use CCS's built-in debug view to see what's currently on the stack- this (in combination with the 'Stack Usage' tab) should help you track down where/what the issue is. That being said, even if it works, that may be a temporary solution to a larger problem.

    I notice that you have a section called DevOpt_Array, allocated at the same location as the FLASHBANK0_VAR memory target. What is FLASHBANK0_VAR being used to store?

    Regards,
    Jason Osborn

  • Hi Jason,

    My instinct here, looking at what you've provided so far, is initially just to increase the size of the stack allocation. In order to test if this would help, run your program with a breakpoint at the beginning of your custom function. There, you should be able to use CCS's built-in debug view to see what's currently on the stack- this (in combination with the 'Stack Usage' tab) should help you track down where/what the issue is. That being said, even if it works, that may be a temporary solution to a larger problem.

    how to increase the size of stack allocation  ?

    I notice that you have a section called DevOpt_Array, allocated at the same location as the FLASHBANK0_VAR memory target. What is FLASHBANK0_VAR being used to store?

    .DevOpt_Array is where the buffer location declared :

    #define FLASHBANK0_VAR              0x08E000U

    uint16_t uint16_Buffer[100] __attribute__((section(".DevOpt_Array")));

    all my variables are store and retrieve from 0x08E000U location 

    Danny

  • Hello Danny,

    The stack allocation is the .stack memory section- although looking at the file again, I see that you're actually fine in that regard, ignore that instruction. I misread part of your file.

    For the FLASHBANK0_VAR section, according to the file you posted, est_data, hal_data, etc. are all not in FLASHBANK0_VAR. For example, est_data is in RAMLS4:

        est_data             : >  RAMLS4,

    What variables specifically are stored there? Additionally, I would highly recommend using the CCS debug view for real time debug.

    Regards,
    Jason Osborn

  • Hi Jason,

    Thanks for your reply, I just re-install both CCS and universal_motorcontrol_lab then problem solved, so I will add my own codes back in, and will take a look of your suggestion for further use ! 

    Danny

  • Hi Jason,

    I have reinstalled the CCS and universal_motorcontrol_lab example, add my own codes piece by piece until I hit the error point. 

    below is red line caused many weird things.

    void doSendBTInitCmd(UARTHandle handle)

    {

        UART_Vars_t *obj = (UART_Vars_t *)uartHandle;

        uint8_t charUartTxCount;

        memset(obj->bleVarObj.msg_14_Obj.charDeviceName, 0x00, 20);

        sprintf((char*)obj->bleVarObj.msg_14_Obj.charDeviceName, "TI-SCI-DEMO");

        .

        .

        . 

        return;

    }

    below is red line removed, program act normal !  

    below is included red line, program act weird, and you can see _c_int00 function inclusive size was too big ? 

    inside _c_int00, it's __TI_Printfi inclusive size occupied most !

    the charDeviceName is uint8_t, do you thing it's caused problem or sprintf function incompatible ?

    typedef struct _Msg_14_t_

    {

        uint8_t     charDeviceName[20];

    } Msg_14_t;

    sprintf((char*)obj->bleVarObj.msg_14_Obj.charDeviceName, "TI-SCI-DEMO");

    EDIT: 

    after some studies on e2e forums, I have changed sprintf to snprintf 

    FROM 

    charUartTxCount = sprintf((char*)obj->bleVarObj.charUartTxBuffer, "AT+NAME%s\r\n", obj->bleVarObj.msg_14_Obj.charDeviceName);

    TO

    charUartTxCount = snprintf(obj->bleVarObj.charUartTxBuffer, sizeof(obj->bleVarObj.charUartTxBuffer), "AT+NAME%s\r\n", obj->bleVarObj.msg_14_Obj.charDeviceName);

    but stil not working !!!!! 

    UPDATE : 

    I use my own codes to replace both snprintf and sprintf now

    Danny

  • Danny,

    Apologies in the delay for getting back to you. I'm glad it looks like you were able to fix the issue- I'm not sure why that was happening with those functions.

    Regards,
    Jason Osborn