How to: RL78/G13 snooze and stop mode configuration

Hello,

I am using IAR EW 4.21.1. I have a R5F100SL targetboard, for which i want to test the snooze and stop mode capabilities. The plan is to use the RTC to wake up every 15 minutes to sample the ADC. If the ADC is above 3.5 Volts, go to normal operation and continuously sample the ADC. If the voltage is not above 3.5V return to stop mode and wake up again 15 minutes later.

I have looked at the ADC snooze example but cant seem to get it to work. With that i mean, when i enter debug, i can see that the ADC never gets initialized.

I have tried on my own, this is my code so far:

    PIOR = 0x00U;
    R_PORT_Create();
    R_CGC_Create();

    
    LED01 = LEDOFF;
    LED02 = LEDOFF;
    
    ADCEN = 1U;  /* supply AD clock */
    ADM0 = _00_AD_ADM0_INITIALVALUE;  /* disable AD conversion and clear ADM0 register */
    ADMK = 1U;  /* disable INTAD interrupt */
    ADIF = 0U;  /* clear INTAD interrupt flag */
    /* Set INTAD low priority */
    ADPR1 = 1U;
    ADPR0 = 1U;
    /* Set ANI0 pin as analog input */
    PM2 |= 0x01U;
    ADM0 = _08_AD_CONVERSION_CLOCK_32 | _00_AD_TIME_MODE_NORMAL_1;
    ADM1 = _C0_AD_TRIGGER_HARDWARE_WAIT | _20_AD_CONVMODE_ONESELECT | _03_AD_TRIGGER_INTIT;
    ADM2 = _00_AD_POSITIVE_VDD | _00_AD_NEGATIVE_VSS | _00_AD_WAKEUP_OFF | _00_AD_AREA_MODE_1 | _01_AD_RESOLUTION_8BIT;
    ADUL = 0xCC; // Set upper limit to 204 /255
    ADLL = 0x99; // Set lower limit to 153/255
    ADS = _00_AD_INPUT_CHANNEL_0;
    ADCE = 1U;    /* enable AD comparator */
    
    //Now ADC should have been created
    
    ADIF = 0U;    /* clear INTAD interrupt flag */
    ADMK = 0U;    /* enable INTAD interrupt */
    
    //Now the ADC should also have been started.
    
    AWC = 1;
    STOP();
    AWC = 0;
    LED01 = LEDON;
    ADIF = 0U;
    ADM2 = _00_AD_WAKEUP_OFF;
   

Hope you can help me out or at least point me in the right direction.

Best regards, Mads