ATSAM3X8E RTC Programming in C (Beginners)

All design tool related questions: compiler, assembler, linker. Embedded programming questions: assembler, C code.

Moderator: nferre

Musazal
Posts: 1
Joined: Tue Apr 23, 2019 10:40 pm

ATSAM3X8E RTC Programming in C (Beginners)

Tue Apr 23, 2019 11:16 pm

Hey there, this is my first ever post in any community forum, so I hope that you won't mind me asking very basic questions.

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.
blue_z
Location: USA
Posts: 2005
Joined: Thu Apr 19, 2007 10:15 pm

Re: ATSAM3X8E RTC Programming in C (Beginners)

Wed Apr 24, 2019 1:21 am

For MCUs try posting at Atmel SMART ARM-based MCUs forums.

Regards

Return to “Development Tools”

Who is online

Users browsing this forum: No registered users and 4 guests