Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 29th October 2009, 05:02 PM   #1
Smile 16F72 digital clock

Hi all,
i am new to PIC. I am trying to create a digital clock with 16F72 and Hitech C.
I want to use timer1 in sleep mode with backup battery when the external power goes down..

I want to get precise timing for half a second to toggle second LED to make it blink once in a second. ie. half of a second in OFF condition and half of a second in ON condition so that i can see a proper blinking of 60 times in a minute.

Please suggest a crystal speed that i can use for this requirement with its prescaler. I dont like to set the timer1 with a initial value because it will cause precision errors in time.. i would like to use bresenhams method for timer to get precise timing. Please suggest...
GreenBeret is offline  
Old 29th October 2009, 06:16 PM   #2
Default

Quote:
Originally Posted by GreenBeret View Post
Hi all,
i am new to PIC. I am trying to create a digital clock with 16F72 and Hitech C.
I want to use timer1 in sleep mode with backup battery when the external power goes down..

I want to get precise timing for half a second to toggle second LED to make it blink once in a second. ie. half of a second in OFF condition and half of a second in ON condition so that i can see a proper blinking of 60 times in a minute.

Please suggest a crystal speed that i can use for this requirement with its prescaler. I dont like to set the timer1 with a initial value because it will cause precision errors in time.. i would like to use bresenhams method for timer to get precise timing. Please suggest...
can u provied it ckt dia.?
sahu is offline  
Old 29th October 2009, 06:47 PM   #3
Default

I dont have any circuit as of now... My idea is to connect PORTB to 7segment display parallely and scan segment using PORTA. I know we can use 32.768KHz crystal, but it will take 8seconds delay to overflow. I want to use this low speed crystal because of power saving... I wanted to 0.5 second notification for second blinking...
GreenBeret is offline  
Old 29th October 2009, 06:54 PM   #4
Red face

Quote:
Originally Posted by GreenBeret View Post
I dont have any circuit as of now... My idea is to connect PORTB to 7segment display parallely and scan segment using PORTA. I know we can use 32.768KHz crystal, but it will take 8seconds delay to overflow. I want to use this low speed crystal because of power saving... I wanted to 0.5 second notification for second blinking...
i have F84 Miniature Real-Time Controller, but it is no usefull for u.
sahu is offline  
Old 29th October 2009, 06:54 PM   #5
Default

With no prescaler it should take 2 seconds to overflow. You can bsf the top two bits on the timer register to cause overflow every 0.5sec
bsf will not reset the prescaler.
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com/
blueroomelectronics is online now  
Old 29th October 2009, 07:29 PM   #6
Default

Thanks blueroomelectronics for your help.
Here i have some more doubts according to your method...
1. While setting top two bits, will i loose some instruction cycles and will it lead to precision errors..?
2. After each overflow, do i need to set the top two bit again.. meaning for each overflow, do i need to bsf two bits?
GreenBeret is offline  
Old 29th October 2009, 07:35 PM   #7
Default

Hopefully your clock is interrupt driven, you won't loose cycles as it'll set them when the count is very low in that register.
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com/

Last edited by blueroomelectronics; 29th October 2009 at 07:38 PM.
blueroomelectronics is online now  
Old 29th October 2009, 07:43 PM   #8
Default

Thanks a lot... I will try it and let u know.. As i am new to PIC, it will take me couple of days to complete the full pgm and circuit...
GreenBeret is offline  
Old 29th October 2009, 11:58 PM   #9
Default

Pic can use as little as 2ma -- no output ports, so you may not need sleep mode.
Russ Hensel is offline  
Old 30th October 2009, 04:12 AM   #10
Default

In sleep a PIC uses much less than 2mA, think uA
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com/
blueroomelectronics is online now  
Old 1st November 2009, 05:44 PM   #11
Default

Hi,
Now i am facing a issue with my code. I enabled the PIE1<0> bit to enable timer1 interrupt. I am getting the interrupts for only sometimes, after that its not giving interrupt. I have a simulator software, when i test in that, i can see the PIE1<0> bit is getting cleared after some time... How this bit gets cleared automatically.. ? Pls help..
GreenBeret is offline  
Reply

Tags
16f72, clock, digital

Thread Tools
Display Modes


Similar
Title Starter Forum Replies Latest
Digital Clock junaid766 Micro Controllers 8 9th December 2008 11:12 PM
digital clock xVorticity General Electronics Chat 5 28th October 2008 08:20 PM
Digital clock amsung2 Micro Controllers 22 5th August 2008 04:51 PM
Digital Clock Overclocked Electronic Projects Design/Ideas/Reviews 19 5th July 2006 10:06 AM
Digital Clock help Tom McCurdy General Electronics Chat 3 14th July 2005 03:48 AM



All times are GMT. The time now is 09:03 PM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker