SAMD rtc counter clears when written to

1 post / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi

I've done a few samd projects but this is the first time I've seen issues with the rtc, I'm using a samd21E18, ext32K osc

I use asf to configure the rtc:

struct rtc_module rtc_instance;

then initialise it like this:

struct rtc_count_config config_rtc_counter;
rtc_count_get_config_defaults(&config_rtc_counter);
rtc_count_init(&rtc_instance, RTC, &config_rtc_counter);
rtc_count_enable(&rtc_instance);

then set the count

rtc_count_set_count(&rtc_instance,1617289702);

the rtc is set to use GCLK2 in conf_clocks.h

#  define CONF_CLOCK_GCLK_2_ENABLE                true				// false
#  define CONF_CLOCK_GCLK_2_RUN_IN_STANDBY        true
#  define CONF_CLOCK_GCLK_2_CLOCK_SOURCE          SYSTEM_CLOCK_SOURCE_XOSC32K
#  define CONF_CLOCK_GCLK_2_PRESCALER             32
#  define CONF_CLOCK_GCLK_2_OUTPUT_ENABLE         false

but the clock doesn't count, and when I update in code (time.servertime is an UInt32_t

rtc_count_set_count(&rtc_instance,time.servertime);

the count register clears to zero

Can anyone help, I've never had this issue with the rtc before, but I've used the SAMD21J18A, I wouldn't have thought the smaller pin out part would make any difference

Regards

Rob Carter

Last Edited: Fri. Apr 2, 2021 - 09:12 AM