Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

High Precision RTC-PIC interface

Status
Not open for further replies.

PatchedUp

Newbie level 1
Joined
Jun 18, 2010
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,292
Hi, first post so be gentle:) Also had a search but couldn't find anything.

Basically what I want to do is connect a rubidium oscillator to a PIC (perhaps via a RTC) and output the accurate time to a set of Nixie tubes.

The atomic output is 10Mhz and doesn't have a 1Hz option.

Could I just sync the PIC clock to 10Mhz using the external clock source? I've heard that using PIC interrupts for real time clocks isn't the greatest idea.

I plan to just output the time, but also have an option to count the date as I want to be able to adjust leap seconds to ensure the clock is always at UTC.

Sorry if any of that was confusing or didn't make sense!
Any help would be much appreciated.
 

mmmm.... yes... you can put the PIC clock pin configured as an external clock (not the INT pin)... it will work at 10MHz... so you will have an 0.4us per instruction.. do your math and plan your hardware... best is to use timers to get exactly 1 second... (maybe set timer1 to 2500 1:1 no prescaler int-clock to get exaclty 1ms and set a counter to 1000)... just an idea....


post your progress so we can help...
 

PatchedUp said:
I've heard that using PIC interrupts for real time clocks isn't the greatest idea.

The biggest issue there is that it may be difficult to maintain an accurate count if something disrupts your ability to cleanly count interrupts. For example, if a watchdog timeout occurs, it may be hard to avoid having your clock disrupted.

One way to deal with this would be to have the clock drive a hardware divider chain which feeds 0.5Hz counter to the PIC (1sec high; 1sec low). Then have the PIC's polling routine check whether the LSB of its second count matches the state of the input. If not, bump the counter.

Some care must be taken with the counter to handle the case of a reset occurring while it is being updated. The simplest approach is probably to keep a primary and "backup" copy of the counter along with a flash to indicate which one is good. To bump the counter:
Code:
  use_sec_flag = 1;
  primary_counter++;
  use_sec_flag = 0;
  secondary_counter = primary_counter;
Then on system startup:
Code:
  if (use_sec_flag)
    primary_counter = secondary_counter;
  use_sec_flag = 0;
Provided the system never goes more than one second without polling the counter, its value should be counted accurately even in the presence of asynchronous resets (assuming that if the reset occurs while the counter is being incremented, the system will see the state of the 1/2Hz clock input after the reset, when the counter value gets un-incremented, and decide to re-increment the counter).
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top