Go Down

Topic: Timer2 Interrups REFUSE to work! :( (Read 5 times) previous topic - next topic

MarkT

We 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?
[ I won't respond to messages, use the forum please ]

TheStig

Ok, here goes

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: MarkT
Insert Quote
We 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 :D, 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
Code: [Select]

//Setup external INT0 interrupt
 EICRA = (1<<ISC01); //Interrupt on falling edge
 EIMSK = (1<<INT0); //Enable INT0 interrupt


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.
Code: [Select]

SIGNAL(TIMER2_OVF_vect){
 seconds += 8; //We sleep for 8 seconds instead of 1 to save more power
 //seconds++; //Use this if we are waking up every second

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

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


MarkT

#7
Sep 19, 2012, 12:10 am Last Edit: Sep 19, 2012, 12:37 am by MarkT Reason: 1
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 won't respond to messages, use the forum please ]


TheStig

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?

Go Up