Adjustable timer with PIC 16F

Thread Starter

Tiago NET

Joined Oct 27, 2015
3
Hello,

Need a code for adjustable timer using PIC 16F628A or 16F877A (have 16F877A on my house, but, 16F628A is easy to find and buy).
This timer maybe count 1 minute to 20 minutes and have a 16x2 LCD display with start/stop, up and down buttons for select time desired.
Thanks for help!
 

jpanhalt

Joined Jan 18, 2008
11,087
I can't help with that language. One easy way would be to use a 32,768 kHz crystal for your timers.

Slightly more difficult (depending on your point of view) would be to use TMR0 and TMR1 with their prescalers. Twenty minutes is 1.2X10^9 microseconds. At 4 MHz, your instruction cycle is 1 us. At a maximum, TMR0 is a 15-bit timer (i.e., 8-bit timer and up to 7-bit prescale); TMR1 is a 19-bit timer (i.e., 16-bit timer and up to 3-bit prescale). So applying that simple analysis gives you 34-bits or 1.7x10^10 counts. You could even go much higher by using registers to keep track or rollovers. For example, a pair of H/L registers will give 16 more bits.

Working out the details is something you can do, as you will need to know the resolution needed. For example, a timer that gave one count/min could be built, but your assignment may want 1-sec resolution or better. I would not go for more precision than required. If it is 1-sec, for example, you might make a 1-second timer and then use that to increment or decrements a pair of registers. There are of course other ways to approach the up/down requirement.
 
Top