dbuezas / lgt8fx

Board Package for Logic Green LGT8F328P LGT8F328D and LGT8F88D
363 stars 87 forks source link

Testing the dead time of timer1 and question of how to use timer3 #94

Closed walon81 closed 3 years ago

walon81 commented 3 years ago

first of all, I tested dead time function of timer1. According to manual, basis signal is OC1B and by setting DTEN bit in TCCR1C, we can enable deadtime. And DTR1 determine deadtime duration. I figure out that DTR1H delay rising timing of OC1B as much as counter clock compare to original OC1B(waveform of OC1B when DTEN is disabled). DTR1L delay rising timing of OC1A.

But I have problem. Timer3 is not work. According to manual, pin 31,32(PD1,PD2) are OC3A and OC3B. timer1 and timer3 have same register structure. just replace 1 to 3(e.g. TCCR3A instead of TCCR1A) and done. But when I tested PD1 and PD2 by oscilloscope, there is no signal. just they are in low voltage(zero voltage with noise) all the way. Interrupt vector is also obscure. Anyone know how to use timer3?

LaZsolt commented 3 years ago

In latest release (v1.0.6) timer3 and interrupt vectors definitions are unfinished. They will be fixed in next release.

maxint-rd commented 3 years ago

@walon81 - once you have edited lgt8xp.h to have proper definitions for OCR3 you can use Timer3 on PF1/PF2. As they share pins with PD1 and PD2, you need to set those to input before the timer output is properly routed to the pin.

(P.S. be careful with PD1 (TX) on the nano-style board. I found that high frequency PWM on that pin can disturb proper recognition of the Holtek USB chip)

walon81 commented 3 years ago

@maxint-rd

@walon81 - once you have edited lgt8xp.h to have proper definitions for OCR3 you can use Timer3 on PF1/PF2. As they share pins with PD1 and PD2, you need to set those to input before the timer output is properly routed to the pin.

(P.S. be careful with PD1 (TX) on the nano-style board. I found that high frequency PWM on that pin can disturb proper recognition of the Holtek USB chip)

I thought PD1 and PD2 are OC3A and OC3B respectively. Actually PF1 and PF2 are timer3 ouput as you said. Timer3 pwm works well. Thanks. For your reference, I use WAVGAT pro mini.

LaZsolt commented 3 years ago

Pin connection table from LGT8Fx8P databook: Pin31Pin32