Hi Chaitanya,
Yes, the problem with the voltage level make sense.
If we assume resistor values according to the scheme in this thread, then:
SW8=OFF, SW9=OFF Vad0=VDDX
SW8=OFF, SW9=ON Vad0=VDDX*(820+1500)/(820+1500+3000)=0.44*VDDX
SW8=ON, SW9=OFF Vad0=VDDX*(820)/(820+3000)=0.21VDDX
The influence of the MCU internal impedance will be rather negligible in this case.
According to the reference manual, the maximum low voltage is 0.35*VDDX for 5V VDDX voltage or 0.3*VDDX for 3.3V VDDX voltage
Just a few notes regarding your code:
1. the EnableInterrupts; macro is the same as __asm(CLI);
So, we may remove the __asm(CLI); line.
I would like to recommend enable interrupts just prior STOP instruction for avoiding interrupt triggers before STOP mode initialization. Lines EnableInterrupts; directly followed by __asm(STOP); are correct.
2. You don't need to clear S-bit in every STOP mode entry. It may be part of MCU's initialization (just once after MCU reset).
3. If you use this AD pin just for wake-up (no analog), you may set up a digital buffer once during initialization.
4. I would like to recommend strictly not use commands like PIFADL_PIFADL0 = 1; for flag clearing (for registers with two or more flags). This command will clear all pending flags in PIFADL register (it is read/modify/write command). Please use for example commands like PIFADL=0x01; or PIFADL = PIFADL_PIFADL0_MASK for clearing single flag. For more details please check AN2554 Clearing and Disabling Interrupt Flags
I hope it helps you.
Best regards
Radek