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.

TMS470M HET specific PWM output

I'm trying to use the TMS470 HET to get two specific PWM signals: a 5MHz 50% duty cycle and a 1Hz 0.01% duty cycle (100 uS high, 999900 uS low). I can get the 5MHz signal by leaving the HR clock at 80Mhz and setting the LR prescale to 3 to get a 100nS LR time but once I get a 100nS loop time it limits the maximum period I can use for the counter on the other PWM channel (since the CNT max is 20bits).

Here is my current HET code:

CNT0 CNT { next=CMP0,reg=A,max=1,data=1};
CMP0 ECMP { next=CNT0,hr_lr=LOW,en_pin_action=ON,cond_addr=CNT1,pin=0,action=PULSEHI,reg=A,data=1,hr_data=0};
CNT1 CNT { next=CMP1,reg=B,max=1000000,data=0};
CMP1 ECMP { next=CNT0,hr_lr=LOW,en_pin_action=ON,cond_addr=CNT0,pin=1,action=PULSELO,reg=B,data=500,hr_data=0};

Here is my PFR config:

hetREG->PFR = 0x0300U;

This gives me a 5MHz 50% signal and a 5Hz 0.5% signal (100uS high, 199.9mS low). The problem I keep running into is that when I get the loop resolution high enough to get the 5MHz signal it limits the loop time so much that I cannot run too many HET functions in the loop.

Advice would be appreciated in generating these two signals.

  • Hello Jotux,

    I have forwarded your question to one of our experts.  Due to the year-end holidays and vacations, There may be a delay in the response.

  • Jotux,

    Which TMS470 device are you using? On the newer devices, the max count value is 25 bits for the CNT instruction.

    You can also consider using a combination of CNT and ECMP instructions as a prescaler. In the following example, the first CNT/ECMP pair provides a scaler of 2 and the second CNT/EMP pair provides a scaler of 512. the low frequency PWM is generated by the third CNT/ECMP pair.

    CNT0 CNT { next=CMP0,reg=A,max=1,data=1};
    CMP0 ECMP {next=CNT0,hr_lr=LOW,en_pin_action=ON,cond_addr=CNT1,pin=0,action=PULSEHI,reg=A,data=1,hr_data=0};

    CNT1 CNT { next=CMP1,reg=T,max=512,data=0};
    CMP1 ECMP { next=CNT0,hr_lr=LOW,en_pin_action=OFF,cond_addr=CNT2,data=256,hr_data=0};

    CNT2 CNT { next=CMP2,reg=B,max=1000000,data=0};
    CMP2 ECMP { next=CNT0,hr_lr=LOW,en_pin_action=ON,cond_addr=CNT0,pin=1,action=PULSELO,reg=B,data=500,hr_data=0};T

    Thanks and regards,

    Zhaohong

  • Jotux,

    I think you're right about the limit on the LR prescaler being /8 (or 3) because to get a 5MHz signal with an 80MHz clock you need to toggle the pin twice every 16 cycles,  and since you can only schedule a toggle once per LR period on the HET you have to have the LR period be 8 cycles.

    For 5MHz, 50% duty cycle, I would recommend looking at the ECLK pin instead of the HET.

    Look at the "ECP" section in the device TRM to find out about ECLK.   (In SPNU495C this is described in section 1.5.6 but I don't know if you're using this particular device family...)

    If you can't use the ECP, then your only fallback I think is going to be to the 'multi-resolution' scheme described in 12.3.4.5

    However with only ~7 instructions to work with, this is still going to be pretty limiting for you so I'd look at the ECP first.

  • Zhaohong,

    Thank you for the assistance. I was able to solve my problem with a variant of your answer:

    CNT0 CNT { next=CMP0,reg=A,max=1,data=1};
    CMP0 ECMP { next=CNT0,hr_lr=LOW,en_pin_action=ON,cond_addr=CNT1,pin=0,action=PULSEHI,reg=A,data=1,hr_data=0};
    CNT1 CNT { next=CMP1,reg=B,max=500,data=0};
    CMP1 ECMP { next=CNT0,hr_lr=LOW,en_pin_action=ON,cond_addr=CNT2,pin=1,action=CLEAR,reg=B,data=0,hr_data=0};
    CNT2 CNT { next=CMP2,reg=B,max=10000,data=0};
    CMP2 ECMP { next=CNT0,hr_lr=LOW,en_pin_action=ON,cond_addr=CNT0,pin=1,action=SET,reg=B,data=10000,hr_data=0};