Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
March 28, 2024, 10:42:01 10:42


Login with username, password and session length


Pages: [1]
Print
Author Topic: master clock please  (Read 3556 times)
0 Members and 1 Guest are viewing this topic.
benaddi6
Newbie
*
Offline Offline

Posts: 24

Thank You
-Given: 1
-Receive: 8


« on: August 06, 2008, 11:38:12 23:38 »

hi
I need project about a master clock system by a PIC ,ho to send a impulse to control a analogue clock
a simailr product http://uk.techni-contact.com/produits/647-7362530-quartz-master-clock.html
thinks
Logged
j0k3r
Junior Member
**
Offline Offline

Posts: 40

Thank You
-Given: 43
-Receive: 18


« Reply #1 on: August 07, 2008, 09:44:18 09:44 »

you can use one of  the internal timers to generate an interrupt every 1second and to toggle a pin, or if you want a realy simple one, chose one of the RTC avaible on market, like Maxim http://para.maxim-ic.com/en/search.mvp?fam=rtc&tree=timers the have some RTC´s (with cristal inclued) with a 1Hz pin output.
Logged
elektrom
Inactive

Offline Offline

Posts: 6

Thank You
-Given: 3
-Receive: 9


« Reply #2 on: November 12, 2008, 10:48:29 10:48 »

You may use 32.768KHz crystal for PIC to get high accuracy timer. But in case that 8,192 instruction per second is enough for your system.
Logged
caveman508
Junior Member
**
Offline Offline

Posts: 41

Thank You
-Given: 12
-Receive: 6

READ, REAd, REad, Read


« Reply #3 on: January 10, 2009, 06:22:24 06:22 »

benaddi6,

Using a CCS compiler, (with this great site, no need to help you there). 

Try this code for a 18F4423, just change the #include on line 1 for your device. 

This example of coding technique is quite poor from a professional point of view, I am sure of that !!.

Many comments within to explain, Please Read through the code.  Do have fun with the knobs.


Hope your coding days will evolve as mine has through the years.  I will try to be here more often for questions.


Caveman


PS.  It worked in Proteus.

Code:

//#include "16f877.h"                        // OR WHAT EVER YOU CHOOSE
#include "18f4423.h"             // CHANGE THIS for your needs

int16 isr_10m_your_delay;     // this is a GLOBAL variable (16 bits), with a name given

// The next line controls the timing
#define YOUR_10M_DELAY_TIME 100 // CHANGE FROM "100" to suit your needs.

// Here is the "reading" of many books part. ahh.. , I will leave that up to you, , The Powerful Interrupt
#int_timer0
void ISR_TIMER0(){

        set_timer0( 15535 );      // reload timer for 10 mS, just simple math.. pre-scaler setting and this count

if (isr_10m_your_delay) isr_10m_your_delay --;   // decrement if NOT zero this time of the interrupt
}

void main(void) {
setup_timer_0( RTCC_INTERNAL | RTCC_DIV_2 );  // get TMR0 initialized for the time base

        enable_interrupts( INT_TIMER0 );     // Allow the INT from TMR0
        enable_interrupts( GLOBAL );             // Allow Interrupts, without GLOBAL, never an Int at all

// Initialize the delay
isr_10m_your_delay = YOUR_10M_DELAY_TIME;
for ( ;; ) {
if ( isr_10m_your_delay == 0 ) {
// Pick your pin in the physical realm
output_toggle(PIN_B4); // CHANGE ME FROM "PIN_B4"
// Re-Initialize the delay
isr_10m_your_delay = YOUR_10M_DELAY_TIME;
}
}
}

« Last Edit: January 10, 2009, 06:25:30 06:25 by caveman508 » Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC