Full Member level 4
How to generate square wave using timers in PIC?
Can anyone pls tell me how to generate square wave using Timers rather than delay in PIC microcontrollers (16F876). Im using CCS COMPILER.
18th July 2008, 21:22
Full Member level 6
Re: Timers in PIC???
You could do the following:
1) Use timer interruption (when the timer overflows) to call the interruption routine that toggles one or more output port state.
2) Timer1 registers can be loaded with a value defined by the user, the difference between 65535 (max count) and the value loaded in the timer registers will be the period of a semi cycle of the output signal. Timer1 clock can be configured and depends on of main clock and the prescaler setting.
3) The period of time wasted by the interruption service routine should not be greater than the period between two timer interruptions