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.

TMS570LC4357: HET program not running correctly with high resolution

Part Number: TMS570LC4357

Hi everyone,

i'm trying to write a small HET program to generate PWM with centered duty cycle to its period. Currently I'm simulating my code with the HET IDE. I've achieved a working program while using only low resolution with the following code:

L00   CNT { next=L01,reg=A,irq=OFF,max=10,data=0};
L01   ECMP { next=L02,hr_lr=LOW,en_pin_action=ON,cond_addr=L00,pin=0,action=SET,reg=A,data=4};
L02   ECMP { next=L00,hr_lr=LOW,en_pin_action=ON,cond_addr=L00,pin=0,action=CLEAR,reg=A,data=6};

This generates PWM with 20% duty cycle centered to the period.

Now, if I want to use high resolution to set duty cycle in smaller steps I tried the following code:

L00   CNT { next=L01,reg=A,irq=OFF,max=10,data=0};
L01   ECMP { next=L02,hr_lr=HIGH,en_pin_action=ON,cond_addr=L00,pin=0,action=SET,reg=A,data=3,hr_data=64};
L02   ECMP { next=L00,hr_lr=HIGH,en_pin_action=ON,cond_addr=L00,pin=0,action=CLEAR,reg=A,data=6,hr_data=64};

If I understand correctly, this should generate PWM with 30% duty cycle. But actually the pin is set high correctly after 3 and a half loops, but never ever cleared to low again. It stays high forever.

I've played a little bit with different settings but didn't find any solutions or hint.

Another point I don't understand is the hr_data=64 command. My prescalers are HR = 1 and LR = 32 and if I look at the simulation I get 32 HR loops in one LR loop. But then, why do I have to write hr_data=64 for a half loop resolution? When I write this value to the instruction, the actual Data HR field in the memory is filled correctly with 16 (half a loop). Where is the conversion happening?

I'd be really happy if someone could explain me what I am doing wrong. 

Greetings,

Steffen

  • Hello Steffen,

    I have forwarded your post to one our NHET experts. They should get back with you soon!
  • Hello Steffen,

    For each N2HET pin, only one instruction specifying a high resolution operation (hr_lr=HIGH) is allowed to execute per loop resolution period. So your second ecmp instruction doesn't generate any action on pin0.

    The solution is to use the sharing feature. The HETXOR register allows a logical XOR of the output signals of two consecutive HR structures N (even) and N+1 (odd).

    Please read the section of 23.2.5.6 in LC43x TRM
  • As the hardware layout already exists, I'm not able to use the pin share feature. If only one high resolution operation per loop resolution is allowed, is it possible to switch the hr_lr setting of the instructions between two LR loops?

    Thanks for your support,
    Steffen Klenk
  • Hello Steffen,

    In HET IDE project property, select XOR, the check pin 0 and pin 1 to XOR:

    The change the NHET code: The first ECMP uses pin0, and the 2nd ECMP uses pin1 --> this means that pin0 uses both pin0 and pin1 HR structiures for it's pin action:

    L00 CNT { next=L01,reg=A,irq=OFF,max=10,data=0};
    L01 ECMP { next=L02,hr_lr=HIGH,en_pin_action=ON,cond_addr=L00,pin=0,action=PULSEHI,reg=A,data=3,hr_data=64};
    L02 ECMP { next=L00,hr_lr=HIGH,en_pin_action=ON,cond_addr=L00,pin=1,action=PULSEHI,reg=A,data=6,hr_data=64};

    This is diagram of pin0 actions (hetm_watch_0_out):

  • Hello Mr. Wang,

    thanks for your detailed explanation of the XOR pin sharing feature. The problem is, that I use existing hardware which uses multiple HET pins for different PWMs. I'm using the HET IDE simulator only for development. For Example I need to use two different PWMs on pin 0 and pin 1. Therefore I can't use the sharing feature, because I need both pins for seperate PWMs. The need of the sharing feature would lead to a redesign of the PCB layout, which of course is not my prefered choice.

    This is the reason why I asked if there is a possibility of changing the hr_lr setting of each instruction in the running HET program between some LR loops. Then I would use the HR feature on the first ECMP instruction to set the pin high. In the next LR loop I would switch the first ECMP instruction to LR and the second ECMP to HR. Then I can set the pin to low again with the HR. 

    Is this possible or do I estimate this issue too simple?

    Thank you very much for your effort.

    Steffen klenk

  • Hello Steffen

    Good point. The following code toggle pin0 with only 1 HR structure:

    PA .equ 0
    LDATA1 .equ 2
    LDATA2 .equ 3
    HDATA1 .equ 64
    HDATA2 .equ 32
    L00 CNT { reg=T, irq=OFF, max= 1ffffffh }
    L01 ECMP { next=L04, cond_addr=L02, en_pin_action=ON, pin= PA, action= SET, reg=T, irq=Off, data = 2, hr_data = 00h }
    L02 RADM64 { next =L04, remote =L01, en_pin_action =ON, cond_addr = L03, pin = PA, comp_mode=ECMP, action= CLEAR, reg = T, irq = OFF, data = LDATA1 , hr_data = HDATA1 }
    L03 RADM64 { next =L04, remote =L01, en_pin_action =ON, cond_addr = L02, pin = PA, comp_mode=ECMP, action= SET, reg = T, irq = OFF, data = LDATA2 , hr_data = HDATA2}
    L04 BR { next= L00, cond_addr=L00, event= NOCOND }

     

    This is the waveform generated by the code above:


     

    L00: increase the counter "data" and the register T

    L01: SET the pin0 or Clear the pin0 when "data" field = T, and delayed by the HR cycles defined in HR_DATA field

    L02: Change L01 control field and data field

    L03: change L01 control field and data field