Backup Mode
Introduction
Backup mode is designed to serve prolonged power-down periods of the processor. In this mode, only the backup area of the device powered by Backup Battery Supply (VBAT) is maintained (Real-Time Clock (RTC), General-Purpose Backup Register (GPBR), Shutdown Controller (SHDWC), Backup System Control Register (BSC_CR), Security Module (SECUMOD), etc.).
The conditions to enter Backup Mode are:
- Event Sampling Clock: MD_SLCK
- Mode Entry: Use SHDWC to shut down all power supplies except VBAT
- Main System Bus Clock (MCK1) at Wake-up: MAINCK (defaults to Main RC osc.)
Enter Backup Mode
Backup mode is entered by shutting down all the power rails of the device except VBAT. It is good practice to use the Shutdown signal (SHDN) output of the Shutdown Controller (SHDWC) for this purpose.
The following figure shows the recommended power-down sequence to place the device in Backup mode. The SHDN signal, output of the Shutdown Controller (SHDWC), signals the shutdown request to the external power supply. This output is supplied by VBAT present in Backup mode. Similar to the power-down sequence, the NRST signal must be asserted prior to turning the device power supplies off.

Exit Backup Mode
The device exits Backup mode when an active wake-up event is triggered by the SHDWC. Upon this wake-up event, the SHDWC automatically toggles its SHDN output back to VBAT, and this signal typically helps to restart all the power supply channels at board level.
The wake-up events to exit Backup mode are:
- PIOBU[3:0]
- WKUP0 pin
- SECUMOD events
- RTT alarm
- RTC alarm
Upon a Wake-up event (WKUP pin, RTC alarm, etc.), the Shutdown Controller automatically toggles its SHDN output back to VBAT to request the external power supply to restart. This power-up sequence is the same as the one shown below:
After wake-up, the device performs a system reset. Re-initialize SDRAM and exit Self-refresh mode. Refer to the "High-Level SDRAM Initialization Procedure" of the SAMA7D6 Series data sheet.

Bare-Metal Implementation Using the MPLAB® Development Ecosystem
To enable WKUP interrupt using MPLAB® Code Configurator (MCC), launch MCC and select Interrupt Configuration from the Plugins drop-down. Enable SHDWC. Select EDGE for Configuration and then click the Generate button.

The code snippet to enter backup mode is shown in the following images:

In this mode, only the backup area of the device powered by VBAT is maintained (RTC, GPBR, SHDWC, BSC_CR, SECUMOD, etc.). To test it, while entering Backup mode, write to GPBR, then read and verify GPBR upon exit.
A sample application file is available here for reference
Test the Application
To test the application:
Copy and paste boot.bin and harmony.bin to the SD card and insert it into the SD card slot at J10. Press the Reset button to run the application.
Now press User switch to interrupt the normal Analog-to-Digital Converter (ADC) application and enter 1 in the serial console window to enter Backup mode.
To exit Backup mode, press the WKPU button on the board.
The serial console output is as shown in the accompanying image:

Note that the system reboots and it executes the application again.
In this mode, only the backup area of the device powered by VBAT is maintained (RTC, GPBR, SHDWC, BSC_CR, SECUMOD, etc.).
To test the backup mode:
Press User switch to interrupt the normal ADC application and enter 6 in the serial console window to test Backup mode.
The GPBR register value written before entering backup mode is retained after exiting it.
The serial console output is as shown in the accompanying image:

Current Measurement in Backup Mode
As per the data sheet, Backup mode current consumption is as follows:
