Smallest Real time clock?

Hello jremington, Do you think It can run on a attiny processor like a attint85,1616,1616? I have a whole bunch of each but no avr of a 328p or anything like it.

Joseph

It need an async timer that accepts an external crystal.
In the case of the AVR you mentioned, ATtiny85 cannot, but ATtiny1616 can.

How about the 1614? And how would i wire that up with which capacitors? Will the same code as jremington posted here will work?

Joseph

Of course, even ATtiny1614 can.

Since the load capacity is built-in, there is no need to connect a capacitor.
Only requires a 32.768kHz crystal. Connect to PB2 and PB3.
It must be placed in the immediate vicinity of the microcontroller and not intersect with other traces.

The code is not written for a relatively new AVR like the ATtiny1614 and cannot be used as it is.
A another code is required when using an asynchronous RTC with an external crystal on the ATtiny1614.

Hello chrisknightly, Thank you. Which code can I use? Sense the avr one I have doesn't work what other sketch Can I use please?

Joseph

Can you write the code yourself?
Do you understand how to use microcontroller peripherals?

There is documentation for usage of tiny1 series RTC from Microchip.

to be honest I'm not good enough for coding. My skills for the past 35 years is been in hardware and figuring out things. I'm a little more then a Noob to be honest. I can mod Things a little in code. Again not really skills in coding.

Joseph

Do you already have ATtiny1614 and 32k Xtal?
Also, have you ever used ATtiny1614 with megaTinyCore?

For example, I write for you the setup code for the ATtiny RTC module.
(It provides interrupts at precision one-second interval.)

Next, you can challenge yourself to code for time management.
How about that?

I have one attiny1616 some place at the moment I can not seem to find it and I have 5 attiny1614. They are in front of me one with a 0.96” oled screen and scrolling text. I got 2 atmega4808 but they backorder at the moment until Jan.

Joseph

What about 32.768kHz crystal for clock?

I have 15 of them.

Joseph

Okay. But please wait, I'm not ready to provide the code right away.

Thank you

Joseph

Hi @josephchrzempiec :grinning:

Sorry for the late reply, I needed work and leisure time. :running_man:

There is something you have to apologize for first. :confounded:
I said in the post above that capacitors aren't needed, but they may be needed.
Please connect your ATtiny1614 a 32.768kHz crystal and two capacitors of about 15pF.

And this code is the code to start the asynchronous timer on ATtiny1614 using an external crystal.
The interrupt increments the unsigned long variable myTime every second.

volatile unsigned long myTime;
void setup() {
  rtcInit();
}
void loop() {
}
void rtcInit() {
  noInterrupts();
  CCP = CCP_IOREG_gc;
  CLKCTRL.XOSC32KCTRLA = 0;
  while (CLKCTRL.MCLKSTATUS & CLKCTRL_XOSC32KS_bm);
  CCP = CCP_IOREG_gc;
  CLKCTRL.XOSC32KCTRLA = CLKCTRL_CSUT_32K_gc | CLKCTRL_ENABLE_bm;
  RTC.CLKSEL = RTC_CLKSEL_TOSC32K_gc;
  while (RTC.PITSTATUS & RTC_CTRLBUSY_bm);
  RTC.PITINTCTRL = RTC_PI_bm;
  RTC.PITCTRLA = RTC_PERIOD_CYC32768_gc | RTC_PITEN_bm;
  CPUINT.LVL1VEC = RTC_PIT_vect_num;
  interrupts();
}
ISR(RTC_PIT_vect) {
  myTime++;
}

I'm using megaTinyCore for compile this code.

You are free to write your own time management code using the myTime variable.

Hello Chris thank you very much. I will try it as soon as I get back home. Dealing with a loss in my wife family.

Joseph

Hello Chris, I do not have any 15pf capacitors. However I do have 22pf. Would they work?

Joseph

Probably there is no problem for test or prototyping.

However, essentially you should check the datasheet of the crystal you are using and use the specified load capacitance.
The crystal frequency will only meet specifications when using the specified load capacitance.

Hello Chris, I did forget to ask one question. On which pins does the crystal go on?

Joseph

Look at the pin diagram in the datasheets of your microcontroller.
Shown as TOSC1 and TOSC2.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.