1 Application

The ideal implementation would be performed entirely in hardware with the external waveforms synchronized to the PIC microcontroller system clock. Fortunately, the combination of the Timer1 Gate, the CLC and the NCO, provide a pure hardware solution. In most cases, the measured pulse and duty cycle is an external waveform with a resolution of at least one clock period. Other methods require software intervention to compensate for timer rollover or register setup between edges. This intervention can cause the accuracy to suffer as well as the minimum and maximum time constraints on the measured waveform. The software routine in these cases could be written in assembly for better accuracy. A software-based method may suffice depending on the accuracy needed in the application.

The duty cycle calculation is the ratio of the pulse and its period, therefore most of the “Duty Cycle Measurement” section references the “Pulse Measurement” section. Some methods rearrange their routine to trigger on the falling to rising edges and vice versa, meanwhile the CLC/NCO and Timer1 Gate methods are set up differently within the “Duty Cycle Measurement” section when compared to the “Pulse Measurement” section.