Other Parts Discussed in Thread: HALCOGEN
Hi, i'm using the NHET for PWM, with the instructions PWCNT (duty cycle) and DJZ (period). I chose those instructions, because HalCoGen also generated those instructions for PWM.
Assuming 100MHz(10 ns) VCLK2 and 64 instructions, I have a Loop Resolution of 640 ns (hr = 1).
Lets say, i want to make a PWM with 19.9kHz period frequency. 19.9kHz means 50251,256ns for one period.
--> CNT(DJZ) = (50251,256 / 640) -1 = 78,52 -1=77,52. --> CNT = 78.
And here is my problem. We got a resolution of something about 0,6%, which is not very good. But it gets much when we look at the resolution of the Duty Cycle.
Maybe we want a DutyCycle of 10%. --> CNT(PWCNT) = 7,752. --> CNT = 8
As you can see, the resolution for the Dutycycle can easily become higher than 5%.
This bad accuracy results from the bad loop resolution. Is there a way to work with High Resolution?