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.

TMDSCNCD28379D: Not entering interrupt

Part Number: TMDSCNCD28379D
Other Parts Discussed in Thread: C2000WARE

Tool/software:

Hi,

I try to step into the interrupt function adc_isr() but it goes directly to the next InitCpuTimer(). How can I do it right?

Thanks,

-Hoongmei Wan

-----------------------------------------------------------------------------

The whole main code is below.

void main(void)

{

      // Step 1. Initialize System Control:

     // This example function is found in the F2837xD_SysCtrl.c file.

     InitSysCtrl();

    // Step 2. Initialize GPIO:

    // This example function is found in the F2837xD_Gpio.c file and

    // illustrates how to set the GPIO to it's default state.

    InitGpio();

    InitEPwmGpio_TZ();

    InitEPwmGpio();

      EALLOW;

               GPIO_SetupPinOptions(72, GPIO_OUTPUT, GPIO_PUSHPULL);

               GPIO_SetupPinOptions(84, GPIO_OUTPUT, GPIO_PUSHPULL);

    EDIS;

    // Step 3. Clear all interrupts and initialize PIE vector table:

    // Disable CPU interrupts

    DINT;

    // Initialize the PIE control registers to their default state.

    // The default state is all PIE interrupts disabled and flags

    // are cleared.

    // This function is found in the F2837xD_PieCtrl.c file.

    InitPieCtrl();

    // Disable CPU interrupts and clear all CPU interrupt flags

    IER = 0x0000;

    IFR = 0x0000;

    // Initialize the PIE vector table with pointers to the shell Interrupt

    // Service Routines (ISR).

    // This function is found in F2837xD_PieVect.c.

    InitPieVectTable();

               // Interrupts that are used in this example are re-mapped to

               // ISR functions found within this file.

               EALLOW;  // This is needed to write to EALLOW protected registers

                              PieVectTable.ADCD1_INT = &adc_isr;

               EDIS;    // This is needed to disable write to EALLOW protected registers

    // Step 4. Initialize the Device Peripherals:

               InitCpuTimers();   // For this example, only initialize the Cpu Timers

               EALLOW;

                              CpuSysRegs.PCLKCR0.bit.TBCLKSYNC =0;

                              ClkCfgRegs.PERCLKDIVSEL.bit.EPWMCLKDIV = 0;

               EDIS;

               initEpwms();

               EALLOW;

                              CpuSysRegs.PCLKCR0.bit.TBCLKSYNC =1;

               EDIS;

               //Configure the ADCs and power them up

               ConfigureADC();

               //Setup the ADCs for software conversions

               SetupADCEpwm();

               // Configure DAC

               DAC_debug();

               // Initialization

               dcParam_Init((dcParam_t*)&dc);

               // Step 5. User specific code, enable interrupts:

               IER |= M_INT1;

// Enable PIE: Group 1 interrupt 1

               PieCtrlRegs.PIEIER1.bit.INTx6 = 1;

               EINT;          // Enable Global interrupt INTM

               ERTM;          // Enable Global realtime interrupt DBGM

//Begin infinite for loop

  for (;;)

    {

      GPIO_WritePin(72, 1);

      GPIO_WritePin(84, 1);

    }//end of infinite loop

}//end of main function

  • Hi,

    The disassembly shows:

    Can anyone help me figure out why I can't enter the interrupt? It is urgent.

    Thanks,

    Hongmei Wan

  • Hi,

    What else do I need to configure for interrupt? EPWM10 is for ADC conversion and I have following ADCs to convert. 

    Thank you and have a wonderful weekend!

    Hongmei Wan

  • Hi Hongmei,

    I apologize for my delayed response.

    The snippet of code you have originally shown will simply set up the interrupt in the ePIE vector table. It will not cause the interrupt to be branched to immediately. One note is that it doesn't look like you have defined your ISR anywhere in the code (unless you have this in a different file?). For an example of proper interrupt configuration usage, I would suggest looking at an example in C2000ware that uses interrupts (sci_loopback_interrupts_cpu01 is a simple example I'd recommend starting with). You should then be able to run the code in debug mode, add a breakpoint to the beginning of the ISR definition, then run the debugger and see it hit the breakpoint on the condition.

    Best Regards,

    Delaney

  • Hi Delaney,

    Thank you very much and I am learning from what you suggested. I am studying example: adc_soc_epwm_cpu01. However I still didn't figure it out. Sometimes it is fine and sometimes it just get out of the interrupt and seems the program is frozen, no refreshing. Could you please take your precious time to review my code below and let me know what settings are missing? 

    void main(void)

    {******

    EALLOW;

    PieVectTable.ADCD1_INT = &adc_isr;

    EDIS;   

    PieCtrlRegs.PIEIER1.bit.INTx6 = 1;

    }

    interrupt void adc_isr(void)

    {******

    AdcdRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;

    PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;

    }

    void SetupADCEpwm(void)

    {******

    EALLOW;

    EPwm5Regs.ETSEL.bit.SOCAEN = 1;

    EPwm5Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;

    EDIS;

    EALLOW;

    AdcaRegs.ADCSOC0CTL.bit.CHSEL = 2;

    AdcaRegs.ADCSOC0CTL.bit.ACQPS = 14;

    AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 0x0D;

    AdcdRegs.ADCSOC0CTL.bit.CHSEL = 3;

    AdcdRegs.ADCSOC0CTL.bit.ACQPS = 14;

    AdcdRegs.ADCSOC0CTL.bit.TRIGSEL = 0x0D;        

    AdcdRegs.ADCINTSEL1N2.bit.INT1SEL = 0;

    AdcdRegs.ADCINTSEL1N2.bit.INT1E = 1;

    AdcdRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;

    EDIS;

    }

    Thanks and have a wonderful weekend,

    Hongmei Wan

  • Hi Hongmei,

    Are you running the adc_soc_epwm_cpu01 example unchanged from the version in C2000ware? Or have you made modifications?

    Best Regards,

    Delaney

  • Hi Delaney,

    The adc_soc_epwm_cpu01 example is good and I made modifications below. ADCDC1 as interrupt and the settings correspondingly are modified. Could you please check if my following settings have any issues? Inside adc_isr, I have another function. If the settings are good, maybe my function kicks the interrupt out. Could you please confirm my settings?

    void main(void)

    {******

    EALLOW;

    PieVectTable.ADCD1_INT = &adc_isr;

    EDIS;   

    PieCtrlRegs.PIEIER1.bit.INTx6 = 1;

    }

    interrupt void adc_isr(void)

    {******

    AdcdRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;

    PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;

    }

    void SetupADCEpwm(void)

    {******

    EALLOW;

    EPwm5Regs.ETSEL.bit.SOCAEN = 1;

    EPwm5Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;

    EDIS;

    EALLOW;

    AdcaRegs.ADCSOC0CTL.bit.CHSEL = 2;

    AdcaRegs.ADCSOC0CTL.bit.ACQPS = 14;

    AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 0x0D;

    AdcdRegs.ADCSOC0CTL.bit.CHSEL = 3;

    AdcdRegs.ADCSOC0CTL.bit.ACQPS = 14;

    AdcdRegs.ADCSOC0CTL.bit.TRIGSEL = 0x0D;        

    AdcdRegs.ADCINTSEL1N2.bit.INT1SEL = 0;

    AdcdRegs.ADCINTSEL1N2.bit.INT1E = 1;

    AdcdRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;

    EDIS;

    }

    Thanks,

    Hongmei Wan

  • Hi Delaney,

    Inside InitSysCtrl(), there is a function called InitFlash(). I enter the function and the order in which the lines of code run is shown in red numbers. I'm wondering why it runs randomly back and forth instead of sequentially and the total number of lines required to run is 9 but it runs like there are 16 lines of code.

    Does this sometimes make the interruption go away? My interrupt sometimes freeze and sometimes everything is fine.

    void InitFlash(void)

    {

        EALLOW;

        Flash0CtrlRegs.FBAC.bit.VREADST = 0x14;                                 (1,4)

        Flash0CtrlRegs.FPAC1.bit.PMPPWR = 0x1;                                   (2,6,9)

        Flash0CtrlRegs.FBFALLBACK.bit.BNKPWR0 = 0x3;                   (3,7,10)

        Flash0CtrlRegs.FRD_INTF_CTRL.bit.DATA_CACHE_EN = 0;    (5,8,11)

        Flash0CtrlRegs.FRD_INTF_CTRL.bit.PREFETCH_EN = 0;          (12)

     

        #if CPU_FRQ_200MHZ

        Flash0CtrlRegs.FRDCNTL.bit.RWAIT = 0x3;                                 (13)

        #endif

        #if CPU_FRQ_150MHZ

        Flash0CtrlRegs.FRDCNTL.bit.RWAIT = 0x2;

        #endif

        #if CPU_FRQ_120MHZ

        Flash0CtrlRegs.FRDCNTL.bit.RWAIT = 0x2;

        #endif

        Flash0CtrlRegs.FRD_INTF_CTRL.bit.DATA_CACHE_EN = 1;    (14)

        Flash0CtrlRegs.FRD_INTF_CTRL.bit.PREFETCH_EN = 1;         (15)

        Flash0EccRegs.ECC_ENABLE.bit.ENABLE = 0xA;                     (16)

        EDIS;

        __asm(" RPT #7 || NOP");

    }

    Thanks,

    Hongmei Wan

  • Hi Hongmei,

    What you have described in the InitFlash() function sounds like it is due to optimizations. If your project has optimizations turned on, it will likely appear that some lines are being stepped to out of order/lines are skipped. That being said, this shouldn't affect how your interrupt runs and generally cannot be disabled for a provided file like F2837xD_SysCtrl.c.

    it just get out of the interrupt and seems the program is frozen, no refreshing

    In this case, if you add a breakpoint inside the ISR, is it being hit but when you step over the line the program is no longer halted? What exactly are you doing after the program hits the breakpoint (if it does)? I'm a little confused by this description.

    To make debugging easier for you, can you verify that Optimizations for your project are turned off? If you haven't changed this setting from how it was in C2000ware then it should already be off.

    Best Regards,

    Delaney

  • Thank you! After making the settings right, everything is working!

    Thanks again and have a great day!

    Hongmei