You'll need an external component to sense when the main power goes down. Maybe like an output of an analog comparator to feed one of the interrupt pins of the SAMD21. Or you could just measure the voltage output of the regulator via one of the ADC and use that to determine whether the main power is out or not.