Go Down

Topic: internal RTC (Read 2 times) previous topic - next topic

mantoui

#5
Dec 06, 2012, 11:37 pm Last Edit: Dec 07, 2012, 12:05 am by mantoui Reason: 1
Now seeing the other RTC thread, I incorporated some of that code, and now I'm getting into the RTC_Handler working.  Code reports that RTC is within 3ppm of system clock -- makes me wonder if code is really using the 32Khz crystal ?

Here are some frequency offsets for other MCU crystals, resonators, RTC ...
Code: [Select]

  processor    oscillator       spec       measured(ppm)
  avr 328p    16Mhz resonator  0.5%     -1330        uno
               16MHz resonator  0.5%     -1422        breadboard 328p
                16MHz crystal    50ppm    -42          breadboard 328p
  avr 328p    11Mhz crystal     ?             -23          3.74v batteries
  avr 328p    11Mhz crystal     ?       -16          5v
  avr 128      14Mhz             ?       1738         no schematic, resonator?

  DUE         12MHz*x crystal    ?       -4
  DUE RTC     32Khz   crystal    ?       3           work in progress
  maple       8MHz*9 crystal    ?        -5
  propeller   5Mhz*16 crystal   ?        -40         board1 (quickstart)
  propeller   5Mhz*16 crystal   ?        -98         board2 (quickstart)

  ds1307 RTC  32khz   cyrstal  20ppm    23           external "watch" crystal
  ds3132 RTC  32khz   cyrstal   2ppm     1           chronodot TCXO i2c
  ds3134 RTC  32khz   cyrstal   2ppm     1           TCXO SPI

  maple RTC   32khz   cyrstal   20ppm     -41         breadboard 512hz ticks
  bad         32khz   crystal   20ppm   -891019      breadboard 512hz ticks

  avr 328  RC  8Mhz     RC      1%       2100         OSCCAL units 3000 ppm
  avr 328p RC  8Mhz     RC      1%       2700         OSCCAL units 5000 ppm
  avr 328p RC  8Mhz     RC      1%       4061         OSCCAL units 4000 ppm
  maple LSI    40KHz    RC     50%     -19659         calibrate with prescale

  beagle      24MHz*x                    -5          ntp drift
  raspberry   19MHz*x                   -16          ntp drift
  dell desk                             -26          ntp drift
  dell laptop                           -14          ntp drift

M4nu

#6
Dec 07, 2012, 06:41 am Last Edit: Dec 07, 2012, 06:45 am by M4nu Reason: 1
@mantoui

Why du you use the RTC creating ticks? The SAM3X has a 24 bit system tick timer. It creates 1 ms ticks. In the arduino software it is already implemented --> millis() // returns the current system time.

mantoui

ticks from the RTC were only used to measure frequency accuracy of the 32khz crystal

M4nu

Oh sorry I understand you wrong. Back to your problem. I think you have to clear the second clear bit (RTC_SCCR_SECCLR). This is a small example which i did before:

Code: [Select]

void RTC_Handler(void)
{
  uint32_t ul_status = rtc.rtc_get_status(RTC);
  rtc.rtc_get_time(RTC, &hour, &minute, &second);
 
  /* Second increment interrupt */
  if ((ul_status & RTC_SR_SEC) == RTC_SR_SEC)
  {     
    rtc_time = "Time: ";
    rtc_time += String(hour);
    rtc_time += ":";
    rtc_time += String(minute);
    rtc_time += ":";
    rtc_time += String(second);
    Serial.println(rtc_time);
   
    rtc.rtc_clear_status(RTC, RTC_SCCR_SECCLR);
  }
 
  /* Time or date alarm */
  if ((ul_status & RTC_SR_ALARM) == RTC_SR_ALARM)
  {
    Serial.println("Alarm");
    rtc.rtc_clear_status(RTC, RTC_SCCR_ALRCLR);
   
  }
}

Go Up