Often the IC datasheet recommends putting a ferrite bead before AVCC pin. First I started wondering if I don't need a flyback diode but than I realized that capacitor is probably able to absorb the excess current.
For back of the napkin calculations I assumed that ferrite bead is an inductor so total energy stored before switching off is \$ CV_0^2 + LI^2 \$.
When the power is cut off all energy needs to be stored in capacitor so energy now is \$ CV_1^2 \$.
So if I want the voltage not to be above some \$V_t\$ I need to have capacitance of:
$$ C_{min} = \frac{LI^2}{V_t^2 - V_0^2} $$
So assuming \$L = \frac{X}{2 \pi f}\$, \$300\,\Omega\ @\ 100\,\mathrm{MHz}\$ ferrite bead, \$I = 20\,\mathrm{mA}\$, \$ V_t = 5\,\mathrm{V}\$, \$ V_0 = 3.3\, \mathrm{V}\$ it gives \$C_{min} \approx 14\,pF\$. Other way round standard \$ C = 0.1\ \mu\mathrm{F}\$ capacitor gives swing of \$0.3\,\mathrm{mV}\$.
Is this reasoning correct? I've made a few spherical cow assumptions and I'm just a beginner.