This is an ideal task for XGATE, read and write in endless loop, but why waste powerful ports like ECT and PWM.
Rich A
Hi Rich,
sorry for my lately reply.
Can you give me some clue, how can i make it work?
Zef
Zef,
CW project wizard generated XGATE enabled project enables XGATE and triggers XGATE software interrupt, which is triggered to run again and again. You need to modify SoftwareTrigger0_Handler in xgate.cxgate and place there code to read PTIT bit and copy it to PTP bit.
This should work for low freq. PWM's.
Please keep in mind however that you need to either have nothing else connected to port P pins (only copied PWM), or use XGSEM register from CPU12X code and csem() / ssem() calls from XGATE code to prevent simultaneous accesses to PTP register. Else weird things may happen.
Hi Edward,
thanks for your clue. I can now relay the PWM. Now i want to know, how can i calculate the dutycycle of the PWM?
I've already made a counter for the Ton and Toff, then calculate it for the dutycycle. But somehow it doesn't work.
Has anyone idea?
Thanks
Zef,
you may use ECT input capture to measure pulse width and period.