Pages: [1]   Go Down
Author Topic: Due and Built in RTC? Anyone Know About clock() ?  (Read 1507 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 58
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't have my Due yet but I've been reading up on it and improving some of my sketches for use with the Due. In a previous sketch, I defined my own function clock() that displayed a clock on an LCD screen.

I was surprised when I tried to migrate this to the Due because it said there was already a clock function. I haven't been able to find the clock function (must be in the core library somewhere) and I have no  idea what it does.

Also I think the Due is supposed to have an on-board (or on-chip?) RTC.

Can anyone provide me with more information regarding the RTC and what the function clock() does? I have no reason to believe these are related, just two curiosities I stumbled upon. It sure would be handy if clock() called returned the time from the RTC!
Logged

St. Leonards-on-Sea, E. Sussex, UK.
Offline Offline
Sr. Member
****
Karma: 2
Posts: 301
Ancient developer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There is an RTC function in the ARM chip, and the board has a 32.768 kHz crystal. Without battery back-up it isn't a lot of use, though. One could presumably be added on a suitable shield. I don't think there is any RTC software support, yet.
« Last Edit: January 17, 2013, 12:38:42 pm by Leon Heller » Logged

Leon Heller
G1HSM

Turku
Offline Offline
Full Member
***
Karma: 0
Posts: 220
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is it possible to solder a battery directly into the board? Is there room for it. I mean a small battery just for the clock.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 58
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hmm ... this could be very useful for my application. I will have to do more research, it seems.
Logged

Offline Offline
Jr. Member
**
Karma: 1
Posts: 80
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, I was looking for making the due RTC work too, so I tried to do it with some register manipulation but the IDE tells me that the registers are not declared... Since I'm not very good, If someone could take a look at my code I could be nice.
Code:
void setup()
{
  Serial.begin(9600);
  if(RTC_WPMR==B01010010010101000100001100000001) bitSet(RTC_WPMR,0);// dissable Write protection
  bitSet(RTC_CR,0);  // request time and date update
  while(bitRead(RTC_SR,0)!=1)  //wait for acknowledge for update
  {}
  bitSet(RTC_SCCR,0);
  RTC_MR=0; //Set hour mode to 24h
  RTC_TIMR=B00000000001000110011000000110000;// set time: 23:30:30
  bitClear(RTC_CR,0);//exit programing mode
  delay(5000);
}
void loop()
{
  rtcToTime(RTC_TIMR);
  delay(10000);
}
void rtcToTime(int rtcTime)
{
  int h=rtcTime>>16;
  int m=(rtcTime>>8)&B000000000000000001111111;
  int s=rtcTime&B00000000000000000000000001111111;
  Serial.print(h);Serial.print(':');Serial.print(m);Serial.print(':');Serial.println(s);
}
Thanks smiley
Logged

L.C.

Brighton, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 47
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@Patouf

Don't know if it will help, but there are RTC register definitions buried deep in the folder tree at e.g.:

    ... \arduino-1.5.1r2\hardware\arduino\sam\system\CMSIS\Device\ATMEL\sam3xa\include\component

Look for files component_rtc.h and instance_rtc.h (there are multiple versions in the tree under the ATMEL folder).

HTH
Jim
Logged

Offline Offline
Jr. Member
**
Karma: 1
Posts: 80
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank's I checked that and it was what I needed smiley
Logged

L.C.

Pages: [1]   Go Up
Jump to: