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.

TZint configurate question

Other Parts Discussed in Thread: MOTORWARE

Hi chris:

I want use PWM1_TZINT . but I get failure. 

I add follow sentences:

1.  In  HAL_initIntVectorTable(halHandle);

static inline void HAL_initIntVectorTable(HAL_Handle handle)
 {
  HAL_Obj *obj = (HAL_Obj *)handle;
  PIE_Obj *pie = (PIE_Obj *)obj->pieHandle;


  ENABLE_PROTECTED_REGISTER_WRITE_MODE;

  pie->ADCINT1 = &mainISR;

  pie->EPWM1_TZINT =&ipmISR;                                                 //add this

  DISABLE_PROTECTED_REGISTER_WRITE_MODE;

  return;
 }

2. In main() ,add:

// enable the TZ1 interrupts
   HAL_enableTz1Ints(halHandle);

in hal.c :

void HAL_enableTz1Ints(HAL_Handle handle)
{
 HAL_Obj *obj = (HAL_Obj *)handle;

 // enable the PIE interrupts associated with the ADC interrupts
 PIE_enableTzInt(obj->pieHandle,PWM_Number_1);

 // enable the Tz interrupts
 Tz_enableInt(obj->pwmHandle[PWM_Number_1]);

    // enable the cpu interrupt for EPWM1_TzINT
    CPU_enableInt(obj->cpuHandle,CPU_IntNumber_2);

 return;
}

3.

In pie.c  add:

void PIE_enableTzInt(PIE_Handle pieHandle,const  PWM_Number_e pwmNumber)   //新增
{
   PIE_Obj *pie = (PIE_Obj *)pieHandle;
   uint16_t index = 1;
   uint16_t setValue = (1 << pwmNumber);


   // set the value
   pie->PIEIER_PIEIFR[index].IER |= setValue;

   return;
}

 In pwm.c add:

void Tz_enableInt(PWM_Handle pwmHandle)
{
 PWM_Obj *pwm = (PWM_Obj *)pwmHandle;

 //set the bits
 pwm->TZEINT |= 0x04;

 return;
}

4. In mymain.c  add ipmISR();

interrupt void ipmISR(void)    //变频器硬件故障
{
  HAL_Obj *obj1 = (HAL_Obj *)halHandle;
   // close 244
   GPIO_setLow(obj1->gpioHandle,GPIO_Number_17);

   HAL_acqTzInt(halHandle,PWM_Number_1);      //clear interrupt flag

}

then in hal.h add:

//!新增
static inline void HAL_acqTzInt(HAL_Handle handle,const PWM_Number_e pwmNumber)
{
 HAL_Obj *obj = (HAL_Obj *)handle;
 TZ_clearIntFlag(obj->pwmHandle[pwmNumber]);
   // Acknowledge interrupt from PIE group 2
    PIE_clearInt(obj->pieHandle,PIE_GroupNumber_2);

}

After these configurated I debug programe. I set GPIO12 low , , this time pwm pulse chang to low. that mean pwm closed. but there no interrupt signal . breakpoint not occur in ipmISR(). 

I check TZINT regester. but it =0x0000.

where did I wrong? help me .   thanks..

yanzheng

best regard!

  • yanzhen,

    MotorWare _12 already uses TZ1.  If you follow the HVMTRKIT you can see how it is enabled

    C:\ti\motorware\motorware_1_01_00_12\sw\modules\hal\boards\hvkit_rev1p1\f28x\f2806x\src\hal.c

    review void HAL_setupFaults

    and GPIO to TZ1 was set-up in void HAL_setupGpios

      // TZ-1
      GPIO_setMode(obj->gpioHandle,GPIO_Number_12,GPIO_12_Mode_TZ1_NOT);

    and in the set-up of the PWMs the trip zones must be initialized by being disabled

    void HAL_setupPwms

          // setup the Trip Zone Select Register (TZSEL)
          PWM_disableTripZones(obj->pwmHandle[cnt]);

     

     

  • Chris: you know I mean.

    I want use TZ1 interrupt . not just enable TZ1 .

    I didn't find enable PWM_TZINT in motorware. so I build these myself. but I DIDN'T success.

    I want to know what I configurate where is wrong. please look my sentents clear.. beg you!

  • Hello Yanzhen Fu,

    Why did you make your own Tz_enableInt?
    You can use PWM_enableTripZoneInt() from pwm.c.

    Also TZEINT is EALLOW protected so you must put EALLOW and DIS between the setting.

    void Tz_enableInt(PWM_Handle pwmHandle)
    {
     PWM_Obj *pwm = (PWM_Obj *)pwmHandle;

        ENABLE_PROTECTED_REGISTER_WRITE_MODE;

     //set the bits
     pwm->TZEINT |= 0x04;

        DISABLE_PROTECTED_REGISTER_WRITE_MODE;

     return;
    }

    Hope this helps.

    Best regards,

    Maria

  • Hi Maria 

    thanks you point EALLOW.and DIS. I have changed.

    but where CAN I find PWM_enableTripZoneInt() from pwm.c.? there isn't this function..!

  • I test it. find regester TZENT=0x0004; that is right,

    but when I set GPIO12(TZINT1) low . programe cann't into ipmISR().

    where did I set wrong?

  • yanzhen fu said:
    where CAN I find PWM_enableTripZoneInt() from pwm.c.

    I see, It means you use F28069 (F/M), right? Because I referred to F28027(F) and PWM_enableTripZoneInt() is there in its pwm.c.

    Btw, did you already put declaration:     interrupt void ipmISR(void); in main.h?

    And   extern interrupt void ipmISR(void); in hal.h?

    Best regards,

    Maria

  • Thanks for pointing out that we have multiple functions in pwm.c for F2802x that we don't for F2806x....I've filed these as bugs...we are trying to do a full clean-up of the MotorWare \drivers this summer.  It's embarassing.

     

  • Yes,I have add that two declares in hal.h and main .h . I knew that. but .... still can,t  interrupt.

  • maybe I shall copy that funtion form F28027F. file

  • Hello Yanzhen Fu,

    I have tested the PWM TZ1 interrupt on my board.

    Because I don't use TZ1 in my board, what I get is TZ1 interrupt occurs right after my code runs. And I check that TZFLG = 0x0005 and my counter that I put in ISR is incremented (which means the TZ interrupt occurs).

    I copied also the APIs from F28027 motorware to pwm.c to make it compatible each other with F28069.

    The modifications are:

    main.c (proj_labxx.c)

    uint16_t  tzcounter = 0; // for testing TZ int

    ...

    interrupt void ipmISR(void) // for testing TZ int
    {
        tzcounter++;

        HAL_tzClearFlag(halHandle, PWM_Number_1, PWM_TripZoneFlag_Global); // this is new (see hal.c)
        HAL_pieAckInt(halHandle, PIE_GroupNumber_2); // this is new (see hal.c)
        return;
    }

    main.h

    interrupt void ipmISR(void); // for testing TZ int

     

    hal.c

    void HAL_pieAckInt(HAL_Handle handle, const PIE_GroupNumber_e groupNumber) {
        HAL_Obj *obj = (HAL_Obj *) handle;
        PIE_clearInt(obj->pieHandle, groupNumber);
    }

    // For testing TZ int
    void HAL_tzClearFlag(HAL_Handle handle, const PWM_Number_e pwmNumber, const PWM_TripZoneFlag_e tripZoneFlag)
    {
        HAL_Obj *obj = (HAL_Obj *) handle;
        PWM_clearTripZone(obj->pwmHandle[pwmNumber], tripZoneFlag);
    }

    void HAL_setupFaults(HAL_Handle handle) {
        HAL_Obj *obj = (HAL_Obj *) handle;
        uint_least8_t cnt;

        // Configure Trip Mechanism for the Motor control software
        // -Cycle by cycle trip on CPU halt
        // -One shot fault trip zone
        // These trips need to be repeated for EPWM1 ,2 & 3
        for (cnt = 0; cnt < 3; cnt++) {
            PWM_enableTripZoneSrc(obj->pwmHandle[cnt],
                    PWM_TripZoneSrc_CycleByCycle_TZ6_NOT);

            PWM_enableTripZoneSrc(obj->pwmHandle[cnt],
                    PWM_TripZoneSrc_OneShot_TZ1_NOT);

            // What do we want the OST/CBC events to do?
            // TZA events can force EPWMxA
            // TZB events can force EPWMxB

            PWM_setTripZoneState_TZA(obj->pwmHandle[cnt],
                    PWM_TripZoneState_EPWM_Low);
            PWM_setTripZoneState_TZB(obj->pwmHandle[cnt],
                    PWM_TripZoneState_EPWM_Low);
        }

        // For testing TZ int
        // enable the PIE interrupts associated with the ADC interrupts
        PIE_enablePwmTzInt(obj->pieHandle,PWM_Number_1);
        // enable the Tz interrupts
        PWM_enableTripZoneInt(obj->pwmHandle[PWM_Number_1], PWM_TripZoneFlag_OST);
        // enable the cpu interrupt for EPWM1_TzINT
        CPU_enableInt(obj->cpuHandle, CPU_IntNumber_2);

        return;
    } // end of HAL_setupFaults() function

    hal.h

    extern interrupt void ipmISR(void); // for testing TZ int

    ....

    static inline void HAL_initIntVectorTable(HAL_Handle handle)
     {
      HAL_Obj *obj = (HAL_Obj *)handle;
      PIE_Obj *pie = (PIE_Obj *)obj->pieHandle;


      ENABLE_PROTECTED_REGISTER_WRITE_MODE;

      pie->ADCINT1 = &mainISR;

      pie->EPWM1_TZINT =&ipmISR;                // for testing TZ int

      DISABLE_PROTECTED_REGISTER_WRITE_MODE;

      return;
     } // end of HAL_initIntVectorTable() function

    ...

    // For testing TZ int
    extern void HAL_tzClearFlag(HAL_Handle handle, const PWM_Number_e pwmNumber, const PWM_TripZoneFlag_e tripZoneFlag);

    I think that's all.
    You may try it in your code.

    Best regards,

    Maria

  • hi : maria:

    I use

    void PIE_enableTzInt(PIE_Handle pieHandle,const  PWM_Number_e pwmNumber)   //新增
    {
       PIE_Obj *pie = (PIE_Obj *)pieHandle;
       uint16_t index = 1;
       uint16_t setValue = (1 << pwmNumber);


       // set the value
       pie->PIEIER_PIEIFR[index].IER |= setValue;

       return;
    }

    replace your " PIE_enablePwmTzInt(obj->pieHandle,PWM_Number_1); "

    I think that is same thing.

    And yes. I can enter ipmISR();

    but  tzcounter continue add. and TZFLAG =0X05;  that mean TZFLAG not clear. and system at TZINT status.

    so . is your same situation?

  • at this time ,I test GPIO12 is high voltage.

  • Hello,

    After I modified ipmISR:

    interrupt void ipmISR(void) // for testing TZ int
    {
        tzcounter++;

        HAL_tzClearFlag(halHandle, PWM_Number_1, PWM_TripZoneFlag_Global);
        HAL_tzClearFlag(halHandle, PWM_Number_1, PWM_TripZoneFlag_CBC);
        HAL_tzClearFlag(halHandle, PWM_Number_1, PWM_TripZoneFlag_OST);

        HAL_pieAckInt(halHandle, PIE_GroupNumber_2);
        return;
    }

     tzcounter was only incremented until 4 and TZFLG became 0 (means the flag is cleared).

    Best regards,

    Maria

  • thanks Maria:

    I have done pwm_TZINT. you are right,must add that two sentences.

    YZ fu

    best regard!

  • That's great!

    Cheers!

    Best regards,

    Maria