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.

CCS/TMS570LS0332: PWM setting problem

Part Number: TMS570LS0332
Other Parts Discussed in Thread: HALCOGEN

Tool/software: Code Composer Studio

Hello

 I want to set the pwm interrupt, pwmEnableNotification(hetREG1,pwm1,pwmEND_OF_PERIOD);

but No matter how I set HAL software “pwm DUTY ,PERIOD,

 this interrupt function Interval period fixed  125 

Machine cycle

void het1LowLevelInterrupt(void)
{
uint32 vec = hetREG1->OFF2;

if (vec < 18U)
{
if ((vec & 1U) != 0U)
{
pwmNotification(hetREG1,(vec >> 1U) - 1U, pwmEND_OF_PERIOD);
}
else
{
pwmNotification(hetREG1,(vec >> 1U) - 1U, pwmEND_OF_DUTY);
}
}
else
{
edgeNotification(hetREG1,vec - 18U);
}
}

I want to change this interrupt time.I try  this function pwmSetSignal(hetRAM1, pwm1, signal); but time is wrong.

  • Hello Whong,

    What is LRP (loop resolution period) used in your HET configuration? and What is your PWM periods used in your test?

    If the HCLK=VCLK=80MHz, and hr=1, and LRP=64*VCLK period=800ns

    The minimum period in HALCoGen generated PWM is 4 LRP: 3.2us. --> 256 VCLK cycles.

    If you use 1.5us, 2us, 3us.., the period will be rounded up to 3.2us.

  • yes LRP =800ns

    hetSIGNAL_t signal;
    signal.period=1000;
    signal.duty=50;
    pwmSetSignal(hetRAM1, pwm1, signal);

    pwmEnableNotification(hetREG1,pwm1,pwmEND_OF_PERIOD);

    but het interrupt function time interval is 125VCLK cycles  .I dont know why?

     Which position do I set is wrong.

    And 

    when

    signal.period=5000;
    signal.duty=50;

    but het interrupt function time interval is 114VCLK cycles .or 133VCLK cycles.I dont know why?

  • Hello Whong,

    The value (125 VCLK) of the INT interval is not correct for your setup. How did you measure the interrupt interval? 

    The interval for your setup is: 1000us*1000/12.5 VCLK cycles

  • hello

    This interrupt function .I see the clock,measure every interval time.

    void het1LowLevelInterrupt(void)
    {
    uint32 vec = hetREG1->OFF2;

    if (vec < 18U)
    {
    if ((vec & 1U) != 0U)
    {
    pwmNotification(hetREG1,(vec >> 1U) - 1U, pwmEND_OF_PERIOD);
    }
    else
    {
    pwmNotification(hetREG1,(vec >> 1U) - 1U, pwmEND_OF_DUTY);
    }
    }
    else
    {
    edgeNotification(hetREG1,vec - 18U);
    }
    }

  • Interval between two interrupt responses

  • It's better to use PMU to measure the clock cycles between 2 interrupts.

  • Hello Whong,

    I did a test with the following code to measure the interrupt interval. There is no problem. 

    My code measures the cycles took by 10 interrupt. If period=100us, the interrupt interval should be 8000 cpu clock cycles. My measurement is 7995 (79950/10) cycles.

    /* USER CODE BEGIN (0) */
    /* USER CODE END */

    /* Include Files */

    #include "sys_common.h"

    /* USER CODE BEGIN (1) */
    #include "het.h"
    #include "sys_pmu.h"
    /* USER CODE END */

    /* USER CODE BEGIN (2) */
    unsigned int gPeriodCount, gDutyCount;
    volatile unsigned long cycles_PMU_start, cycles_PMU_end, cycles_PMU_measure;
    /* USER CODE END */

    int main(void)
    {
    /* USER CODE BEGIN (3) */
    hetSIGNAL_t pwmSignal;
    gPeriodCount=0;
    gDutyCount=0;

    hetInit();
    _enable_IRQ();

    _pmuInit_();
    _pmuEnableCountersGlobal_();

    pwmEnableNotification(hetREG1, 0x0, pwmEND_OF_DUTY);
    pwmEnableNotification(hetREG1, 0x0, pwmEND_OF_PERIOD);

    pwmSignal.duty = 50;
    pwmSignal.period = 100;
    pwmSetSignal(hetRAM1, 0x0, pwmSignal);

    pwmStart( hetRAM1, 0x0);
    while(1);

    /* USER CODE END */

    return 0;
    }


    /* USER CODE BEGIN (4) */
    void pwmNotification(hetBASE_t * hetREG, uint32 pwm, uint32 notification){
    if(notification == pwmEND_OF_DUTY){
    gDutyCount++;
    }
    if((notification == pwmEND_OF_PERIOD) && (pwm==0)){
    gPeriodCount++;

    if (gPeriodCount ==1){
    _pmuResetCounters_();
    _pmuStartCounters_(pmuCYCLE_COUNTER);
    cycles_PMU_start = _pmuGetCycleCount_();
    }
    if (gPeriodCount ==11){
    _pmuStopCounters_(pmuCYCLE_COUNTER);
    cycles_PMU_end = _pmuGetCycleCount_();
    cycles_PMU_measure = cycles_PMU_end - cycles_PMU_start;
    }
    }
    }

    /* USER CODE END */

  • Thank you 

     where  I can see pmu paper.

      I do my test ,but  it  is not  same as  you .when(gPeriodCount ==11) cycles_PMU_measure=72074

     And  if (gPeriodCount ==2),cycles_PMU_measure is 197.

    when gPeriodCount ==2,what result you test?

  • Please refer to ARM cortex-R4 TRM for PMU:

    http://infocenter.arm.com/help/topic/com.arm.doc.ddi0363g/DDI0363G_cortex_r4_r1p4_trm.pdf

    I don't see any problem for gPeriodCount ==2/4/10/100.