Once the RTC, CPUINIT, and SLPCTRL modules have been added and reconfigured using Atmel | START, the application code needs to be updated in Atmel Studio.
#include <avr/sleep.h>
//Set sleep mode to STANDBY mode
set_sleep_mode(SLEEP_MODE_STANDBY);
sleep_enable();
//Enter into sleep mode
sleep_cpu();
/* RTC Overflow Interrupt handling */
ADC_0_start_conversion(10); //start ADC conversion on channel 10
ISR(ADC0_RESRDY_vect)
{
/* ADC result ready Interrupt handling: start USART transmission */
USART_0_write(ADC_0_get_conversion_result()); //USART write ADC result
while(!(USART0.STATUS & USART_TXCIF_bm)); //wait for USART TX complete
USART0.STATUS = USART_TXCIF_bm; //Clear TXCIF flag
/* The interrupt flag has to be cleared manually */
ADC0.INTFLAGS = ADC_RESRDY_bm;
}
In the ADC result ready interrupt routine, the ADC result ready interrupt will trigger for the ADC result to be sent over USART.