I've got a custom-made board with Atmel SAM4S MCU on it. Currently this board doesn't have anything but MCU, decoupling capacitors, one LED on PA20 and a battery holder for powering up the MCU. Programming is occurring using SWD protocol via SWDIO/SWDCLK pins without any pullups. NRST is connected to a simple button that connects it to ground when pressed (according to the manual NRST doesn't require any external components). No crystals are used at all, MCU uses internal 4/8/12 RC oscillator and slow clock.
All works fine, I can access the MCU and it performs well.
But the problem is - I can't get it to consume less than ~400uA even in Backup mode. I've created a simple program that configures all PIOs as inputs with pull-ups (tried to configure them as outputs, with different combination of pull-ups,pull-downs,opendrain inputs/outputs, but it seems to consume the least amount of current when configured as input with pull-ups) and then immediately goes into backup mode without any wakeup source. I've googled everything, found several Atmel manuals about low power modes and they all recommend to configure SAM3/SAM4 ports as outputs with pull-down. But if I do that - MCU starts to consume ~4mA at 4MHz in backup mode agains ~0.7mA in Active mode at 4MHz.
Can anybody help me? What I might be doing wrong? I'm using ASF to configure all ports and I've configured MATRIX to use all ports as GPIO before going to sleep.