So I am trying to build a small watch project, I cant really go so much into detail as I am just prototyping. I am not exactly "great" in C, but know my way around the basics.

However, timer interrupts or fuse settings continue to boggle me. At this point I have gotten counting and LEDs to light up on my board, good signs. Once that went good, I moved onto timing the danged thing. I am basing my code heavily off of sparkfuns "bigTime" watch code (on their website if you need it). Basically the clock is running off of a 32.768kHz crystal, as sort of an RTC. This is timed by generating interrupts on the clock pins. Unfortunately, my code doesnt seem to work. I have LEDs that light up, and my button interrupts work, but I CANNOT get the external crystal to trigger the interrupt.

//The interrupt occurs when you push the buttonSIGNAL(INT0_vect){ //When you hit the button, we will need to display the time //if(show_the_time == FALSE) show_the_time = TRUE;}The button? What button?

Does your code work if you quit trying to sleep? What use is a sleeping watch?

//The interrupt occurs when you push the buttonSIGNAL(INT0_vect){ //When you hit the button, we will need to display the time //if(show_the_time == FALSE) show_the_time = TRUE;}

The button? What button? - there is a button interrupt attached to pin D2 i believe. This is used to wake the watch from sleep.

Does your code work if you quit trying to sleep? What use is a sleeping watch? - No and no, when I set always on to true, the timer2 interrupt is still running but never called, never incrementing the timer/clock variables. Watch is sleeping to save massive amounts of power.

Code is attached in arduino formatting (as INO file). Code also references a couple LIBs but they should be in arduino program by default. This is literally all the code i have on this, soo...

Also attached is the schematic and rough board layout in EAGLE.

Posted by: MarkTInsert QuoteWe need to see your circuit to understand this, some of your code suggests you are clocking timer2's prescaler at 32768Hz, is this true and if so how?

To be honest, I have no idea what you just said. I am just trying to get timer2 to inturrupt every 8s from a 32.768 crystal. Most of my code was copied from sparkfuns example, so it *should* work, but as I said, hardware and software level inturrupts are not exactly my strongpoint.

Posted by: PaulS Not working saves even more power? Just trying to eliminate possible areas of conflict.

Yep , well at least at the moment...

I'd check... I also don't see where you connect that ISR to that pin. The attachInterrupt() function is usually called to make an association.I think this deos it

Which pins would that be? What code, of yours, is supposed to respond to those interrupts? Pins TOSC1 & TOSC2 if I got the names right. Just XTAL1 and XTAL2 on the schematic. This code is what is supposed to be run when it interrupts.

Can't read those files, despite having Eagle, wrong version - if you export as image then its much more friendly to us (not everyone uses Eagle). In general it helps to present all the relevant information (provide links, photos, etc)

Looking at the bigTime thing on sparkfun it seems all confused (comments about not using delay / delayMicroseconds, yet it does use them. It seems to be using a non-standard fuse option on the ATmega, namely the internal RC oscillator (allowing TOSC1/2 to be used as timer clock). Is your microcontroller suitable programmed with the right fuse options? Note if using the internal oscillator you may have to use an ICMP programmer to upload sketches (I may be a bit rusty about this).

The quality control on sparkfun site is not the best I've seen BTW, so I wouldn't trust the online files to necessarily be up-to-date or even self-consistent (if not tell them so they notice and fix it for others).

Other comments on the sparkfun page imply a standard Arduino Mini 8MHz can be used, which obviously is not the case as the crystal is hard-wired on that board yet the sparkfun schematic shows a 32,768Hz xtal, not an 8MHz one.

[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

I used an ICSP programmer to set the fuse settings accordingly. I think they are correct, AVR studio 4 says its using the internal oscillator. I will email sparkfun and see if that is the most recent version of the code and see what they are doing- anything specific i need to ask?

Hmmm, have you proof that the 32768 xtal is actually oscillating? Have you calculated load caps as per table 8-8 and associated text in the datasheet? Have you read section 17.9 of the datasheet and checked the code is DTRT?

[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

They are not used at the moment, they are just places for xtal load caps but I havnt loaded the crystal at all.

*******I'm a little curious about this bit:

Code: if(seconds > 59){ minutes++; seconds = seconds - 59; }

if(minutes > 59){ hours++; minutes = minutes - 59; }

Aren't there 60 seconds to a minute, and 60 minutes to an hour?

Yes, but I am using > not >=. So anything greater than 59 (60), will go back down to 1. Course I need to add 0s to it but havnt yet.

*****Hmmm, have you proof that the 32768 xtal is actually oscillating? Have you calculated load caps as per table 8-8 and associated text in the datasheet? Have you read section 17.9 of the datasheet and checked the code is DTRT?

I don't have an oscilloscope but I can check (earliest I could do it is tomorrow). I think somewhere else in the data sheet it says not to use load crystals for that slow of a crystal, I have not added them (but can).

Read through 17.9 and didnt undertand much of it , or rather, I understood most of it, just not how to create a practical example.

Thank you all so much with your help thus far, I really appreciate it and am eager to learn more. Sorry my coding is not up to par, but i really dont code that often so I never quite "learned" it. Mostly just taught myself...