How to generate square wave using timers in PIC?

Status
Not open for further replies.

Faizan Jawaid

Full Member level 3
Joined
Jul 17, 2008
Messages
189
Helped
23
Reputation
46
Reaction score
5
Trophy points
1,298
Location
Karachi, Pakistan
Activity points
2,336
Can anyone pls tell me how to generate square wave using Timers rather than delay in PIC microcontrollers (16F876). Im using CCS COMPILER.

Regards.
 

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
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…