Hi,
I have posted this in the TMS570 forum, but responses were not about the subject. Now nearly the same post in the High Rel forum:
At the moment the controller can generate 3 PWM signals on HET 0, HET2 and HET3.
The frequency should be the same, but with different duty cylces. It works correctly in the current state but I´m unsatisfied with the resolution of the duty cycle.
The frequency of the quartz crystal is 10MHz. By using the PLL with factor 4 the controller reaches 40MHz.
Now to the HET initialization and program code:
HETPFR = 0x0000000C;
LR-Prescaler is 1 and HR-Prescaler is 12.
HETPRY = 0x04;
HETDCLR = 0xffffffff; // Clear HET output latches
HETDIR = 0xffffffff; // Set HET as GIO outputs
HETGCR |= ON; // Start HET
The HR-prescaler cannot be reduced cause otherwise not the whole program would be executed.
So I have 40MHz/12=3.33MHz.
Counter value=66 for 50KHz (3.33MHz/50KHz=66)
HET Program Code:
; Implement a counter that uses register A and rolls over at 0x042 L00: CNT {next=L01, reg=A, irq=OFF, max=0x0042, data=0} ; PWM (20% duty cycle PIN0) L01: ECMP {next=L02, reg=A, hr_lr=LOW, en_pin_action=ON, pin=CC0, action=PULSELO, irq=Off, data=0x000D} ; When count reaches 0, trigger interrupt. Now the ISR loads ; a new data value into the MOV32 instruction. L02: ECMP {next=L03, reg=A, hr_lr=LOW, en_pin_action=OFF, pin=CC0, cond_addr=L03, irq=ON, data=0x0 } ; When count reaches 0x42, load the next ECMP compare value used ; for PWM generation. L03: ECMP {next=L04, reg=A, hr_lr=LOW, en_pin_action=OFF, pin=CC0, cond_addr=L04, irq=OFF, data=0x0042 } ; Load ECMP data value with the value stored in the MOV32 instruction L04: MOV32 {next=A01, remote=L01, control=OFF, init=OFF, type=IMTOREG&REM, reg=NONE, data=0x0, hr_data=0x0} ; PWM (20% duty cycle PIN2) A01: ECMP {next=A02, reg=A, hr_lr=LOW, en_pin_action=ON, pin=CC2, action=PULSELO, irq=Off, data=0x000D} A02: ECMP {next=A03, reg=A, hr_lr=LOW, en_pin_action=OFF, pin=CC2, cond_addr=A03, irq=ON, data=0x0 } A03: ECMP {next=A04, reg=A, hr_lr=LOW, en_pin_action=OFF, pin=CC2, cond_addr=A04, irq=OFF, data=0x0042 } A04: MOV32 {next=B01, remote=A01, control=OFF, init=OFF, type=IMTOREG&REM, reg=NONE, data=0x0, hr_data=0x0} ;PWM (20% duty cycle PIN3) B01: ECMP {next=B02, reg=A, hr_lr=LOW, en_pin_action=ON, pin=CC3, action=PULSELO, irq=Off, data=0x000D} B02: ECMP {next=B03, reg=A, hr_lr=LOW, en_pin_action=OFF, pin=CC3, cond_addr=B03, irq=ON, data=0x0 } B03: ECMP {next=B04, reg=A, hr_lr=LOW, en_pin_action=OFF, pin=CC3, cond_addr=B04, irq=OFF, data=0x0042} B04: MOV32 {next=L00, remote=B01, control=OFF, init=OFF, type=IMTOREG&REM, reg=NONE, data=0x0, hr_data=0x0}
In the start initialization of HET program duty cycles are the same I know. The frequency of the PWM is always the same.
In the main program its necessary to change the duty cycles in certain time periods. This works already.
Does anybody know how I can improve the duty cycle resolution by modifying the program code (only). A resolution of 200 steps (or more) would be desirable.
Or is it possible that only one HET output with the right duty cycle is active and the other two are disabled and I can control which is active from the main program??
If this is possible the resolution should be better. But at the moment I don´t know how to impliment. I need the HET code for this solution.
Best regards
Chris