Jp3141
Well-known member
I am trying to build a system which needs to generate a variable duty cycle PWM signal at about 125 kHz (this is a digital signal, not an analog output). I also need to measure the time between one edge of the PWM and another input signal (in the few microseconds range). I have trouble getting started -- how to configure the PWM, and how to setup interrupts.
Basically I need:
A digital output pin with PWM at a frequency of about 125 kHz (variable from ~ 100 to ~ 150 kHz) which can vary duty cycle from ~ 10 % (e.g. on for 1 us) to ~ 50 % (4 us on). I need duty cycle variable with fine resolution (1 % = 100 ns).
A digital input pin that triggers and interrupt upon a change (falling edge) and indicates the time interval between this input and the previous PWM edge.
I have difficulty getting started on this; I think all I need is some example code that I can massage to meet my needs. I would prefer something that is self-contained (i.e. not using additional complex libraries), but at this point, anything would be helpful.
Can anyone point to some T3 samples/examples ?
Thanks
JP
Basically I need:
A digital output pin with PWM at a frequency of about 125 kHz (variable from ~ 100 to ~ 150 kHz) which can vary duty cycle from ~ 10 % (e.g. on for 1 us) to ~ 50 % (4 us on). I need duty cycle variable with fine resolution (1 % = 100 ns).
A digital input pin that triggers and interrupt upon a change (falling edge) and indicates the time interval between this input and the previous PWM edge.
I have difficulty getting started on this; I think all I need is some example code that I can massage to meet my needs. I would prefer something that is self-contained (i.e. not using additional complex libraries), but at this point, anything would be helpful.
Can anyone point to some T3 samples/examples ?
Thanks
JP