I would use say CCP1 pin of the PIC and confiure the CCP Module in Capture Mode. In this mode, the module will capture the 16-bit value of the TMR1 Register when the CCP1 pin changes state. This will occur with minimal intervention from your program. The resolution at 20MHz will be in steps of 200nS to a maximum of 16 bits - ie 13.1mS. Use the integral Hardware of the PIC to help you with this one. Unfortunately you're limited to the size of the TMR1 register. Alternatively, you can use instant interrupts in conjunction with TMR1 to give you longer time periods if you enable the prescaler. Without knowing what's going on in your application it's difficult to recommend.




Bookmarks