So here is the thing. I'm trying to program RTC in ARDUINO DUE having ATSAM3X8E. I'm making ASF board project in Atmel Studio but since I don't know how to simulate it (by adding break points and checking values in the corresponding registers) and that is because it asks for Custom Programming Tool and I have searched for any software but didn't find any. So I'll be grateful if you could also help me in this area. So, for now I write my C program in Atmel Studio and compile it. But to debug it or check the output, I use Arduino IDE and write the similar program and start serial communication to check the values in the register. Coming to the RTC problem, whenever I start serial communication, it always starts from zero and after 9 it starts jumping to random values. I have loaded the initial values in the RTC_TIMR reg. as below but it seems to have no effect. Also, whenever I try to mask the register to get a certain bit, it always gives zero on serial monitor. Here is my code:
Code: Select all
void setup() {
SystemInit();
WDT->WDT_MR = WDT_MR_WDDIS;
Serial.begin(9600);
}
void loop() {
RTC_CALR_CENT(0b10100);
RTC_CALR_YEAR(0b10011);
RTC_CALR_MONTH(0b100);
RTC_CALR_DAY(0b10);
RTC_CALR_DATE(0b10111);
RTC_TIMR_HOUR(0b10);
RTC_TIMR_MIN(0b101);
RTC->RTC_TIMR|=RTC_TIMR_SEC(0b11);
while(1)
{
Serial.print((RTC->RTC_TIMR));
Serial.println("\n");
}
}
So, what I'm asking is if anyone can direct me in the right direction or give me the basic code for RTC programming for the particular micro-controller. Also I've to program it only in C and the CMSIS example code is beyond my understanding. The above code is written in main in Atmel studio without serial.