Pages: [1]   Go Down
Author Topic: Due RTC  (Read 672 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 1
Posts: 80
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, I am trying to get the due rtc working using register manipulation, following the method in the Sam doc. I tried this:
Code:
void setup()
{
  Serial.begin(9600);
  if(RTC_WPMR==0b01010010010101000100001100000001) 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=0b00000000001000110011000000110000;// 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)&0b000000000000000001111111;
  int s=rtcTime&0b00000000000000000000000001111111;
  Serial.print(h);Serial.print(':');Serial.print(m);Serial.print(':');Serial.println(s);
}
but the ide said that all the register names( RTC_WPMR, RTC_CR, etc...) were not declared. So if anyone can help me to make the ide understand that I am referring to  the sam's registers and not a variable?
Thanks
« Last Edit: January 19, 2013, 05:31:54 am by Patouf » Logged

L.C.

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

Never mind, I found what was wrong. Arduino uses different names for the register, that's why it didn't worked...
Logged

L.C.

Pages: [1]   Go Up
Jump to: