SAML21 RTC clock after exit backup mode

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi everyone, I am working on saml21. I can't find solution about this problem. Could you help me ?

RTC works in Backup mode but how do I get the RTC clock information after exit backup mode? RTC is resetting when I try to get it normally.

if (system_get_reset_cause() == SYSTEM_RESET_CAUSE_BACKUP

){

printf("Alarm 1 is worked\r\n");

printf("System wake up from BACKUP reset\r\n");

configure_rtc_calendar();

configure_rtc_callbacks();

rtc_calendar_get_time(&rtc_instance,&time);

printf("%d:%d:%d\r\n",time.hour,time.minute,time.second);

//I get 0:0:0 

}

else

{

//////////////////////////////////////////////////////////////////////////

rtc_calendar_get_time_defaults(&time);

time.year   = 2013;

time.month  = 1;

time.day    = 1;

time.hour   = 0;

time.minute = 0;

time.second = 13;

configure_rtc_calendar();// I set the alarm to 7 seconds later;

configure_rtc_callbacks();

rtc_calendar_set_time(&rtc_instance, &time);

printf("RTC Setup\r\n");

rtc_calendar_get_time(&rtc_instance, &time);

printf("%d:%d:%d\r\n",time.hour,time.minute,time.second);

//I get 0:0:13, RTC is working

//Test Backup

test_backup_mode();

//////////////////////////////////////////////////////////////////////////

}

Usart output;

RTC Setup
0:0:13

Alarm 1 is worked
System wake up from BACKUP reset
0:0:0
0:0:1
0:0:2
0:0:3
0:0:4

//It resets after 7 seconds from backup mode so, alarm is working correctly but the clock does not seem right. I set the alarm to 7 seconds later  so, It must start 0:0:20 but it starts 0:0:0

 

 

This topic has a solution.
Last Edited: Wed. Jan 17, 2018 - 09:33 PM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
I found the solution, I deleted the (rtc_calendar_reset) in "rtc_calendar_init" in "src\ASF\sam0\drivers\rtc\rtc_sam_l_c\rtc_calendar.c"
void rtc_calendar_init(
		struct rtc_module *const module,
		Rtc *const hw,
		const struct rtc_calendar_config *const config)
{
	/* Sanity check arguments */
	Assert(module);
	Assert(hw);
	Assert(config);

	/* Initialize device instance */
	module->hw = hw;

	/* Turn on the digital interface clock */
	system_apb_clock_set_mask(SYSTEM_CLOCK_APB_APBA, MCLK_APBAMASK_RTC);

	/* Select RTC clock */
	OSC32KCTRL->RTCCTRL.reg = RTC_CLOCK_SOURCE;
	
	/*
	struct system_gclk_chan_config gclk_chan_conf;
	system_gclk_chan_get_config_defaults(&gclk_chan_conf);
	gclk_chan_conf.source_generator = GCLK_GENERATOR_1;
	
	system_gclk_chan_set_config(RTC_GPR_NUM, &gclk_chan_conf);
	system_gclk_chan_enable(RTC_GPR_NUM);*/

    /////////////////////////////////////////////
	/* Reset module to hardware defaults. */
	//rtc_calendar_reset(module);
	//////////////////////////////////////////////

	/* Save conf_struct internally for continued use. */
	module->clock_24h           = config->clock_24h;
	module->year_init_value     = config->year_init_value;

#if (RTC_INST_NUM == 1)
	_rtc_instance[0] = module;
#else
	/* Register this instance for callbacks*/
	_rtc_instance[_rtc_get_inst_index(hw)] = module;
#endif

	/* Set config. */
	_rtc_calendar_set_config(module, config);
}

 

Last Edited: Wed. Jan 17, 2018 - 09:33 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi CaglarG ,

I am newbie to the ATMEL family.

I am also facing same problem, when i press reset button then my calendar (date & time) resets and starts from begin.

I tried above solution then also problem not resolved.

I am implementing calendar activity on my SAML21 board with RTC battery backup.

 

How can I implement this calendar activity runs continuously when I press reset button with backup battery?

please help me.

Thanks in Advance

 

Last Edited: Wed. Dec 26, 2018 - 07:10 AM