Best microcontroller for timekeeping

hgmjr

Joined Jan 28, 2005
9,027
Ooopss, my bad. The DS1375 is designed to take its input from a crystal oscillator rather than a crystal.

hgmjr
 

Thread Starter

Manmeet Singh

Joined May 21, 2008
37
And how do you plan to set the clock and program the feeding? Keypad, display?


Clock, Program, Day, Hour, Minute. A total of 5 pushbuttons with the output of the current clock time and program settings on an LCD display. What I am hoping todo is find a pushbutton that lights up when pushed once and turns off when pushed again this would help the user realize that they are currently modifying the clock or program as only these two buttons would light up when pressed. Does anybody know a PB that fits that description?
 

MMcLaren

Joined Feb 14, 2010
861
Clock, Program, Day, Hour, Minute. A total of 5 pushbuttons with the output of the current clock time and program settings on an LCD display. What I am hoping todo is find a pushbutton that lights up when pushed once and turns off when pushed again this would help the user realize that they are currently modifying the clock or program as only these two buttons would light up when pressed. Does anybody know a PB that fits that description?
Just select any one of a number of lighted push buttons. The switch portion and the LED portion are separate circuits. Use a "switch state latch" in your switch debounce/management code to filter out all but a "new press" switch state and toggle a switch flag from on-to-off or from off-to-on with each "new press" (emulated toggle switch). Light the LED accordingly.
 

Thread Starter

Manmeet Singh

Joined May 21, 2008
37
Just select any one of a number of lighted push buttons. The switch portion and the LED portion are separate circuits. Use a "switch state latch" in your switch debounce/management code to filter out all but a "new press" switch state and toggle a switch flag from on-to-off or from off-to-on with each "new press" (emulated toggle switch). Light the LED accordingly.

Hmm I guess it was to late for me to be thinking about the right wording for those pushbuttons but yes I managed to find a few suitable ones. Yea debouncing will need to be done for sure now if I can only remember how todo that...to used to writing in Verilog not enough C! Thanks for the tips.
 

Thread Starter

Manmeet Singh

Joined May 21, 2008
37
Now I am familiar with interrupts but not with the ATMega 328 found on the Arduino UNO. How do I set up the interrupt ISRs?

According to http://arduino.cc/en/Reference/AttachInterrupt
This is not for a specific ATMega processor
Example

void setup()
{
pinMode(pin, OUTPUT);
attachInterrupt(0, blink, CHANGE);
}

void blink()
{
...
}

but then elsewhere I have found this kind of code for the ATMega8


// Definition of interrupt names
#include < avr/io.h >
// ISR interrupt service routine
#include < avr/interrupt.h >

// Install the interrupt routine.
ISR(INT0_vect) {
....
}

void setup() {
...
// Global Enable INT0 interrupt
GICR |= ( 1 < < INT0);
// Signal change triggers interrupt
MCUCR |= ( 1 << ISC00);
MCUCR |= ( 0 << ISC01);
....
}

Neither of them clear an interrupt flag in the ISR either which is strange
to me. Any tips on the right way todo this?

Thanks
 

hgmjr

Joined Jan 28, 2005
9,027
Now I am familiar with interrupts but not with the ATMega 328 found on the Arduino UNO. How do I set up the interrupt ISRs?

According to http://arduino.cc/en/Reference/AttachInterrupt
This is not for a specific ATMega processor
Example

void setup()
{
pinMode(pin, OUTPUT);
attachInterrupt(0, blink, CHANGE);
}

void blink()
{
...
}

but then elsewhere I have found this kind of code for the ATMega8


// Definition of interrupt names
#include < avr/io.h >
// ISR interrupt service routine
#include < avr/interrupt.h >

// Install the interrupt routine.
ISR(INT0_vect) {
....
}

void setup() {
...
// Global Enable INT0 interrupt
GICR |= ( 1 < < INT0);
// Signal change triggers interrupt
MCUCR |= ( 1 << ISC00);
MCUCR |= ( 0 << ISC01);
....
}

Neither of them clear an interrupt flag in the ISR either which is strange
to me. Any tips on the right way todo this?

Thanks
The information gleaned from the Arduino website describing the proper way to set up the interrupt is the one you need to follow.

The other technique you have posted is for the non-Ardunio case where you are writing the interrupt service low level handling code. The Arduino is managing the low level interrupt setup for you using the attachInterrupt() function call.

hgmjr
 

Thread Starter

Manmeet Singh

Joined May 21, 2008
37
The information gleaned from the Arduino website describing the proper way to set up the interrupt is the one you need to follow.

The other technique you have posted is for the non-Ardunio case where you are writing the interrupt service low level handling code. The Arduino is managing the low level interrupt setup for you using the attachInterrupt() function call.

hgmjr
In my attempt to find an answer for this question I found that almost every pin on the arduino is capable of generating a pin change interrupt. Am i right to assume that attachInterrupt does all the low level coding of setting up the control registers for the explicitly stated external interrupt pins yet the second technique is used to set up all the control registers manually for pins that you want to generate pin change interrupts?
 

hgmjr

Joined Jan 28, 2005
9,027
In my attempt to find an answer for this question I found that almost every pin on the arduino is capable of generating a pin change interrupt. Am i right to assume that attachInterrupt does all the low level coding of setting up the control registers for the explicitly stated external interrupt pins yet the second technique is used to set up all the control registers manually for pins that you want to generate pin change interrupts?
I have not used the interrupt feature on the Arduino but I do know that the ATMEGA328 on which the Arduino board is based does support interrupts on all of its IO pins.

As for the Arduino high-level language, you are correct in the assumption that the low-level register manipulation required to set up and use interrupts is taken care of by the Arduino interrupt function calls provided.

hgmjr
 

Thread Starter

Manmeet Singh

Joined May 21, 2008
37
I have not used the interrupt feature on the Arduino but I do know that the ATMEGA328 on which the Arduino board is based does support interrupts on all of its IO pins.

As for the Arduino high-level language, you are correct in the assumption that the low-level register manipulation required to set up and use interrupts is taken care of by the Arduino interrupt function calls provided.

hgmjr
Great appreciate the confirmation now I just need to sift through the datasheet to figure out the register names. And as for the Arduino interrupt function manipulating the registers itself for those 2 external interrupts I guess its safe to assume it clears the interrupt flag upon executing the respective ISR?
 

hgmjr

Joined Jan 28, 2005
9,027
Great appreciate the confirmation now I just need to sift through the datasheet to figure out the register names. And as for the Arduino interrupt function manipulating the registers itself for those 2 external interrupts I guess its safe to assume it clears the interrupt flag upon executing the respective ISR?
You need not worry about the names of the registers in the AVR if you use the Arduino. All of the manipulation at the register level is completely taken care of by the Arduino interrupt library function. You can just relax and enjoy the ride.

If you needed to stop the interrupt for any reason, I would imagine that you would execute a detachInterrupt();

hgmjr
 
Top