6.8.2.1.2 Code

Add to the main application source file, outside of any functions:
#define DATA_LENGTH (16)
struct dac_module dac_instance;
struct rtc_module rtc_instance;
struct events_resource event_dac;
static volatile bool transfer_is_done = false;
static uint16_t dac_data[DATA_LENGTH];
Callback function:
void dac_callback(uint8_t channel)
{
    UNUSED(channel);

    transfer_is_done = true;
}
Copy-paste the following setup code to your user application:
void configure_rtc_count(void)
{
    struct rtc_count_events  rtc_event;

    struct rtc_count_config config_rtc_count;

    rtc_count_get_config_defaults(&config_rtc_count);

    config_rtc_count.prescaler           = RTC_COUNT_PRESCALER_DIV_1;
    config_rtc_count.mode                = RTC_COUNT_MODE_16BIT;
#ifdef FEATURE_RTC_CONTINUOUSLY_UPDATED
    config_rtc_count.continuously_update = true;
#endif

    rtc_count_init(&rtc_instance, RTC, &config_rtc_count);

    rtc_event.generate_event_on_overflow = true;

    rtc_count_enable_events(&rtc_instance, &rtc_event);

    rtc_count_enable(&rtc_instance);
}
void configure_dac(void)
{
    struct dac_config config_dac;

    dac_get_config_defaults(&config_dac);

#if (SAML21)
    dac_instance.start_on_event[DAC_CHANNEL_0] = true;
#else
    dac_instance.start_on_event = true;
#endif

    dac_init(&dac_instance, DAC, &config_dac);

    struct dac_events events =
#if (SAML21)
        { .on_event_chan0_start_conversion = true };
#else
        { .on_event_start_conversion = true };
#endif

    dac_enable_events(&dac_instance, &events);
}
void configure_dac_channel(void)
{
    struct dac_chan_config config_dac_chan;

    dac_chan_get_config_defaults(&config_dac_chan);

    dac_chan_set_config(&dac_instance, DAC_CHANNEL_0,
            &config_dac_chan);

    dac_chan_enable(&dac_instance, DAC_CHANNEL_0);
}
Define a data length variables and add to user application (typically the start of main()):
uint32_t i;
Add to user application initialization (typically the start of main()):
configure_rtc_count();

rtc_count_set_period(&rtc_instance, 1);

configure_dac();

configure_dac_channel();

dac_enable(&dac_instance);

configure_event_resource();

dac_register_callback(&dac_instance, DAC_CHANNEL_0,
        dac_callback,DAC_CALLBACK_TRANSFER_COMPLETE);

dac_chan_enable_callback(&dac_instance, DAC_CHANNEL_0,
        DAC_CALLBACK_TRANSFER_COMPLETE);

for (i = 0;i < DATA_LENGTH;i++) {
    dac_data[i] = 0xfff * i;
}