SAM4 Reset Controller (RSTC)

Similar documents
APPLICATION NOTE. Atmel AT03261: SAM D20 System Interrupt Driver (SYSTEM INTERRUPT) SAM D20 System Interrupt Driver (SYSTEM INTERRUPT)

AT11512: SAM L Brown Out Detector (BOD) Driver. Introduction. SMART ARM-based Microcontrollers APPLICATION NOTE

AT03262: SAM D/R/L/C System Pin Multiplexer (SYSTEM PINMUX) Driver. Introduction. SMART ARM-based Microcontrollers APPLICATION NOTE

APPLICATION NOTE. AT06863: SAM4L Peripheral Event Controller (PEVC) SAM4L Peripheral Event Controller (PEVC) ASF PROGRAMMERS MANUAL

AT10942: SAM Configurable Custom Logic (CCL) Driver. Introduction. SMART ARM-based Microcontrollers APPLICATION NOTE

SAM4L Asynchronous Timer (AST)

AT07942: SAM4L Asynchronous Timer (AST) Driver. Introduction. SMART ARM-based Microcontrollers APPLICATION NOTE

SAM4L Liquid Crystal Display (LCDCA)

APPLICATION NOTE. AT05567: TC Capture on External Interrupt with the Event System on SAM D20. Preface ASF PROJECT DOCUMENTATION

AT03975: Getting Started with SAM L21. Descripton. Features. SMART ARM-Based Microcontroller APPLICATION NOTE

AT60142H/HT. Rad-Hard 512Kx8 Very Low Power CMOS SRAM ERRATA-SHEET. Active Errata List. Errata History. Abbreviations. 1.

AVR42789: Writing to Flash on the New tinyavr Platform Using Assembly

APPLICATION NOTE. AT6486: Using DIVAS on SAMC Microcontroller. SMART ARM-Based Microcontroller. Introduction. Features

AT09381: SAM D - Debugging Watchdog Timer Reset. Introduction. SMART ARM-based Microcontrollers APPLICATION NOTE

APPLICATION NOTE. Atmel AT02260: Driving AT42QT1085. Atmel QTouch. Features. Description

AVR134: Real Time Clock (RTC) Using the Asynchronous Timer. Features. Introduction. AVR 8-bit Microcontrollers APPLICATION NOTE

AT06467: Getting started with SAM D09/D10/D11. Features. Description. SMART ARM-based Microcontrollers APPLICATION NOTE

Ethernet1 Xplained Pro

APPLICATION NOTE. Atmel AVR1638: XMEGA RTC Calibration. 8-bit Atmel Microcontrollers. Features. Introduction

AVR1518: XMEGA-A1 Xplained Training - XMEGA Clock System. 8-bit Atmel Microcontrollers. Application Note. Prerequisites.

EDBG. Description. Programmers and Debuggers USER GUIDE

USER GUIDE EDBG. Description

USER GUIDE. Atmel Segment LCD1 Xplained Pro. Preface

APPLICATION NOTE. Atmel AT03304: SAM D20 I 2 C Slave Bootloader SAM D20. Description. Features

ATECC108/ATSHA204 USER GUIDE. Atmel Firmware Library. Features. Introduction

ATAES132A Firmware Development Library. Introduction. Features. Atmel CryptoAuthentication USER GUIDE

OLED display with pixels resolution Ambient light sensor CPU load Analog filter Quadrature Encoder with push button Digital I/O

USER GUIDE. Atmel OLED1 Xplained Pro. Preface

USER GUIDE. Atmel QT1 Xplained Pro. Preface

Native route discovery algorithm

AT21CS Series Reset and Discovery. Introduction. Serial EEPROM APPLICATION NOTE

Hardware Prerequisites Atmel Xplained Pro Evaluation Kit Atmel WINC1500 extension USB Micro Cable (TypeA / MicroB)

This user guide describes how to run the Atmel ATWINC3400 Bluetooth Low Energy (BLE) Provisioning demo from out-of-box conditions.

APPLICATION NOTE. Atmel AVR3009: Driving QTouch Device with I 2 C Interface. Atmel QTouch. Introduction

USER GUIDE. Atmel QT6 Xplained Pro. Preface

AVR1303: Use and configuration of IR communication module. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

QT3 Xplained Pro. Preface. Atmel QTouch USER GUIDE

AVR1503: Xplain training - XMEGA Programmable Multi Interrupt Controller 8-bit Microcontrollers Application Note Prerequisites

QT2 Xplained Pro. Preface. Atmel QTouch USER GUIDE

APPLICATION NOTE. AT03324: Atmel REB212BSMA-EK Quick Start Guide. Atmel MCU Wireless. Introduction

APPLICATION NOTE. Atmel AT03160: Migrating Bootloader from ATxmega128A1 to other Atmel XMEGA Devices. Atmel AVR XMEGA. Features.

AVR1922: Xplain Board Controller Firmware 8-bit Microcontrollers Application Note Features 1 Introduction

DGILib USER GUIDE Atmel-42771A-DGILib_User Guide-09/2016

USER GUIDE. ZigBit USB Stick User Guide. Introduction

APPLICATION NOTE. How to Securely Switch Atmel s LIN Transceiver ATA6662/ATA6662C to Sleep Mode ATA6662/ATA6662C. Concerning Atmel ATA6662

APPLICATION NOTE. Atmel QT4 Xplained Pro User Guide ATAN0114. Preface

Section 5 SERCOM. Tasks SPI. In this section you will learn:

Atmel AVR1926: XMEGA-B1 Xplained Getting Started Guide. 8-bit Atmel Microcontrollers. Application Note. Features. 1 Introduction

APPLICATION NOTE. Atmel AT03782: Using Low Power Modes in SAM4N Microcontroller. Atmel 32-bit Microcontroller. Features.

ATtiny104 Xplained Nano. Preface. AVR 8-bit Microcontrollers USER GUIDE

APPLICATION NOTE. Atmel AT01080: XMEGA E Schematic Checklist. Atmel AVR XMEGA E. Features. Introduction

AVR1501: Xplain training XMEGA Timer/Counter 8-bit Microcontrollers Application Note Prerequisites 1 Introduction

AVR32752: Using the AVR32 UC3 Static Memory Controller. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

Intel Stress Bitstreams and Encoder (Intel SBE) 2017 AVS2 Release Notes (Version 2.3)

APPLICATION NOTE. AT11008: Migration from ATxmega16D4/32D4 Revision E to Revision I. Atmel AVR XMEGA. Introduction. Features

Atmel AVR1619: XMEGA-B1 Xplained Demonstration. 8-bit Atmel Microcontrollers. Application Note. Features. 1 Introduction

USER GUIDE. ATWINC1500 Xplained Pro. Preface

Atmel QT600 Quick Start Guide Touch Solutions

Atmel AVR32847: Migration from/to the UC3L0 64/32/16 from/to the UC3L0 256/ bit Atmel Microcontrollers. Application Note.

APPLICATION NOTE. Atmel AVR057: Internal RC Oscillator Calibration for ATtiny4/5/9/10/20/40. 8-bit Atmel Microcontrollers. Features.

STK521. User Guide B AVR 01/12

USER GUIDE. Atmel PROTO1 Xplained Pro. Preface

Atmel AVR ATxmega384C3 microcontroller OLED display with 128x32 pixels resolution Analog sensors. Ambient light sensor Temperature sensor

AVR42772: Data Logger Demo Application on XMEGA A1U Xplained Pro. Introduction. Features. AVR XMEGA Microcontrollers APPLICATION NOTE

APPLICATION NOTE. 3-lead CONTACT Package Usage. ATSHA204A, ATECC108A, and ATECC508A. Introduction. 3-lead CONTACT Package

ATtiny817 QTouch Moisture Demo User Guide. Description. Features. AVR 8-bit Microcontrollers USER GUIDE

a clock signal and a bi-directional data signal (SCL, SDA)

APPLICATION NOTE. AT04470: Differences between SAM D21 Variants A, B, and L. 32-bit Microcontroller. Introduction

SAMA5D2 Quad SPI (QSPI) Performance. Introduction. SMART ARM-based Microprocessor APPLICATION NOTE

Open Source Used In TSP

AT88CK101 HARDWARE USER GUIDE. Atmel CryptoAuthentication Development Kit. Atmel CryptoAuthentication AT88CK101 Daughterboard

Documentation Roadmap for Cisco Prime LAN Management Solution 4.2

HALCoGen TMS570LS31x Help: example_sci_uart_9600.c

Atmel and the use of Verilator to create uc Device Models

APPLICATION NOTE. Atmel AVR2131: Lightweight Mesh Getting Started Guide. Atmel MCU Wireless. Features. Description

Atmel ATMXT143E touchscreen controller Capacitive touch ITO 320 x 240 pixel LCD display with SPI interface LED backlight

AVR1315: Accessing the XMEGA EEPROM. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Atmel AT697F. Rad-Hard 32-bit SPARC v8 Processor ERRATA SHEET. Active Errata List

USER GUIDE. ATmega168 Xplained Mini User Guide. Introduction

ATECC508A Public Key Validation. Introduction. Atmel CryptoAuthentication APPLICATION NOTE

APPLICATION NOTE. Generating Random Secrets. ATSHA204A, ATECC108A, and ATECC508A. Description. Topics

ED1021 I/O Expander with UART interface & analog inputs

AVR32401: AVR32 AP7 Linux Interfacing DataFlash. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Smart RF Device Family - Getting Started Guide. Features. Description. References ATAN0115 APPLICATION NOTE

SBAT90USB162 Atmel. SBAT90USB162 Development Board User s Manual

Ecma International Policy on Submission, Inclusion and Licensing of Software

LBAT90USB162 Atmel. LBAT90USB162 Development Board User s Manual

AVR4018: Inertial Two (ATAVRSBIN2) Hardware User's Guide. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR1508: Xplain training - XMEGA DAC 8-bit Microcontrollers Application Note Features 1 Introduction

APPLICATION NOTE. Atmel AVR536: Migration from ATmega644 to ATmega644A. 8-bit Atmel Microcontrollers. Introduction

APPLICATION NOTE. Atmel AVR116: Wear Leveling on DataFlash. 32-bit Atmel Microcontrollers. Features. Description. Wear leveling

OLED display Sensors readout. Light sensor Temperature sensor

AVR32 UC3 Software Framework... User Manual

Atmel LF-RFID Kit Comparison Chart. Application Note. Atmel LF-RFID Kit Comparison Chart. 1. Description

End User License Agreement

Ecma International Policy on Submission, Inclusion and Licensing of Software

TERMS & CONDITIONS. Complied with GDPR rules and regulation CONDITIONS OF USE PROPRIETARY RIGHTS AND ACCEPTABLE USE OF CONTENT

I/O1 Xplained Pro. Preface. Atmel MCUs USER GUIDE

AT91 ARM Thumb-based Microcontroller. Application Note. AT91SAM7X and AT91SAM7XC Microcontroller Series Schematic Check List. 1.

Atmel AVR1924: XMEGA-A1 Xplained Hardware User's Guide. 8-bit Atmel Microcontrollers. Application Note. Preliminary. Features.

Transcription:

APPLICATION NOTE AT06864: SAM4 Reset Controller (RSTC) ASF PROGRAMMERS MANUAL SAM4 Reset Controller (RSTC) This driver for SAM devices provides an interface for the configuration and management of the device's Reset Controller functionality. The Reset Controller manages all Resets of the System including; external devices (via the NRST pin), Processor Reset and Peripheral Reset. It also provides the status of the last reset source. The following peripherals are used by this module: RSTC (Reset Controller) The outline of this documentation is as follows: Prerequisites Module Overview Special Considerations Extra Information Examples API Overview

Table of Contents SAM4 Reset Controller (RSTC)... 1 Software License... 4 1. Prerequisites... 5 2. Module Overview... 6 2.1. NRST Manager... 6 2.1.1. NRST Signal or Interrupt... 6 2.1.2. NRST External Reset Control... 6 2.2. Reset State Manager... 6 2.2.1. General Reset... 6 2.2.2. Backup Reset... 6 2.2.3. User Reset... 6 2.2.4. Software Reset... 6 2.2.5. Watchdog Reset... 7 2.2.6. Reset State Priorities... 7 3. Special Considerations... 8 4. Extra Information... 9 5. Examples... 10 6. API Overview... 11 6.1. Macro Definitions... 11 6.1.1. Macro RSTC_BACKUP_RESET... 11 6.1.2. Macro RSTC_CPMR_KEY_PASSWD... 11 6.1.3. Macro RSTC_GENERAL_RESET... 11 6.1.4. Macro RSTC_NRST_HIGH... 11 6.1.5. Macro RSTC_NRST_LOW... 11 6.1.6. Macro RSTC_SOFTWARE_RESET... 11 6.1.7. Macro RSTC_USER_RESET... 11 6.1.8. Macro RSTC_WATCHDOG_RESET... 11 6.2. Function Definitions... 12 6.2.1. Function rstc_assert_reset_of_coprocessor()... 12 6.2.2. Function rstc_deassert_reset_of_coprocessor()... 12 6.2.3. Function rstc_disable_user_reset()... 12 6.2.4. Function rstc_disable_user_reset_interrupt()... 13 6.2.5. Function rstc_enable_user_reset()... 13 6.2.6. Function rstc_enable_user_reset_interrupt()... 13 6.2.7. Function rstc_get_reset_cause()... 14 6.2.8. Function rstc_get_status()... 14 6.2.9. Function rstc_reset_extern()... 14 6.2.10. Function rstc_set_external_reset()... 14 6.2.11. Function rstc_start_software_reset()... 15 7. Extra Information for Reset Controller Driver... 16 7.1. Acronyms... 16 7.2. Dependencies... 16 7.3. Errata... 16 7.4. Module History... 16 8. Examples for Reset Controller Driver... 17 8.1. Quick Start guide for SAM RSTC driver... 17 8.1.1. Basic Use Case... 17 8.1.2. Setup Steps... 17 8.1.3. Usage Steps... 17 2

8.2. Reset Controller (RSTC) Example... 18 8.2.1. Purpose... 18 8.2.2. Requirements... 18 8.2.3. Description... 18 8.2.4. Main Files... 18 8.2.5. Compilation Information... 18 8.2.6. Usage... 18 Index... 21 Document Revision History... 22 3

Software License Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of Atmel may not be used to endorse or promote products derived from this software without specific prior written permission. 4. This software may only be redistributed and used in connection with an Atmel microcontroller product. THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 4

1. Prerequisites There are no prerequisites for this module. 5

2. Module Overview The Reset Controller contains an NRST Manager and a Reset State Manager. It runs at Slow Clock (SCLK) and generates the following: Processor and Watchdog Timer reset Embedded peripheral reset Co-processor and Co-processor peripheral reset (SAM4C devices only) External device reset (via the NRST pin) These reset signals are asserted by the Reset Controller acting on external events or as the result of an action performed by software. The Reset State Manager controls the operation of reset signals and provides a signal to the NRST Manager when an assertion of the NRST pin is required. 2.1 NRST Manager To control an external device reset the NRST Manager shapes the NRST assertion period using a programmable timer. While asserted, after power-up, NRST is an output and driven low. When the programmable time period has elapsed the pin behaves as an input and all the system is held in reset if NRST is tied to GND by an external signal. 2.1.1 NRST Signal or Interrupt The NRST Manager samples the NRST pin at Slow Clock (SCLK) speed and drives this pin low when required by the Reset State Manager. When the line is detected as being low a User Reset is reported to the Reset State Manager. However, the NRST Manager can be programmed not to trigger a reset when NRST is asserted. The Reset controller can also be programmed to generate an interrupt instead of generating a reset. 2.1.2 NRST External Reset Control The NRST Manager can assert NRST for a programmable time period of between 60μs and 2s (approximately). This allows the Reset Controller to shape the NRST pin level and thus to guarantee that the NRST line is low for a time that is compliant with any external devices also connected to the system reset. 2.2 Reset State Manager The Reset State Manager handles the different reset sources and generates the internal reset signals. 2.2.1 General Reset A general reset occurs when either a Power-on-reset is detected or the Supply Controller detects a Brownout or Voltage regulation loss. 2.2.2 Backup Reset A Backup reset occurs when the chip returns from Backup Mode. The core_backup_reset signal is asserted by the Supply Controller when a Backup reset occurs. 2.2.3 User Reset If User Reset is enabled then the state is entered when a low level is detected on the NRST pin. When User Reset is entered both the Processor Reset and the Peripheral Reset are asserted. The User Reset state is left when NRST rises and the processor clock is re-enabled as soon as NRST is confirmed high. 2.2.4 Software Reset The Reset Controller allows software to assert the the following reset signals: Reset the processor and the Watchdog Timer 6

Reset all the embedded peripherals Reset the Co-processor (SAM4C devices only) Reset all the embedded peripherals associated with the Co-processor (SAM4C devices only) Assert NRST for a programmable time period Note The embedded peripheral reset also includes the memory system and the Remap Command and is generally used for debugging purposes. For SAM4C devices the Co-processor peripheral reset only affects the embedded peripherals associated with the Co-processor. The processor's peripherals are not reset. 2.2.5 Watchdog Reset The Watchdog Reset is entered when a watchdog fault occurs. 2.2.6 Reset State Priorities The Reset State Manager manages the following priorities between the different reset sources, given in descending order: General Reset Backup Reset Watchdog Reset Software Reset User Reset Particular cases are listed below: When in User Reset: A watchdog event is impossible because the Watchdog Timer is being reset A software reset is impossible because the processor reset is being activated When in Software Reset: A watchdog event has priority over the current state The NRST has no effect When in Watchdog Reset: The processor reset is active and so a Software Reset cannot be programmed A User Reset cannot be entered 7

3. Special Considerations System designs using any external devices that require a software controllable reset signal assertion longer than two seconds should use a dedicated I/O output of the microcontroller. 8

4. Extra Information For extra information, see Extra Information for Reset Controller Driver. This includes: Acronyms Dependencies Errata Module History 9

5. Examples For a list of examples related to this driver, see Examples for Reset Controller Driver. 10

6. API Overview 6.1 Macro Definitions 6.1.1 Macro RSTC_BACKUP_RESET #define RSTC_BACKUP_RESET 6.1.2 Macro RSTC_CPMR_KEY_PASSWD #define RSTC_CPMR_KEY_PASSWD 6.1.3 Macro RSTC_GENERAL_RESET #define RSTC_GENERAL_RESET 6.1.4 Macro RSTC_NRST_HIGH #define RSTC_NRST_HIGH 6.1.5 Macro RSTC_NRST_LOW #define RSTC_NRST_LOW 6.1.6 Macro RSTC_SOFTWARE_RESET #define RSTC_SOFTWARE_RESET 6.1.7 Macro RSTC_USER_RESET #define RSTC_USER_RESET 6.1.8 Macro RSTC_WATCHDOG_RESET #define RSTC_WATCHDOG_RESET 11

6.2 Function Definitions 6.2.1 Function rstc_assert_reset_of_coprocessor() Assert the reset of the Co-processor. void rstc_assert_reset_of_coprocessor( Rstc * p_rstc, const uint32_t reset) Note This function is for SAM4C devices only. Table 6-1. Parameters Data direction Parameter name Description [in, out] p_rstc Module hardware register base address pointer [in] reset The reset to be asserted as a bitmask, which could be RSTC_CPMR_CPEREN (peripheral reset) and/or RSTC_CPMR_CPROCEN (core reset). 6.2.2 Function rstc_deassert_reset_of_coprocessor() Deassert the reset of the Co-processor. void rstc_deassert_reset_of_coprocessor( Rstc * p_rstc, const uint32_t reset) Note This function is for SAM4C devices only. Table 6-2. Parameters Data direction Parameter name Description [in, out] p_rstc Module hardware register base address pointer [in] reset The reset to be deasserted as a bitmask, which could be RSTC_CPMR_CPEREN (peripheral reset) and/or RSTC_CPMR_CPROCEN (core reset). 6.2.3 Function rstc_disable_user_reset() 12

Disable User Reset. void rstc_disable_user_reset( Rstc * p_rstc) Table 6-3. Parameters Data direction Parameter name Description [in, out] p_rstc Module hardware register base address pointer 6.2.4 Function rstc_disable_user_reset_interrupt() Disable the User Reset interrupt. void rstc_disable_user_reset_interrupt( Rstc * p_rstc) Table 6-4. Parameters Data direction Parameter name Description [in, out] p_rstc Module hardware register base address pointer 6.2.5 Function rstc_enable_user_reset() Enable User Reset. void rstc_enable_user_reset( Rstc * p_rstc) Table 6-5. Parameters Data direction Parameter name Description [in, out] p_rstc Module hardware register base address pointer 6.2.6 Function rstc_enable_user_reset_interrupt() Enable the User Reset interrupt. void rstc_enable_user_reset_interrupt( Rstc * p_rstc) Table 6-6. Parameters Data direction Parameter name Description [in, out] p_rstc Module hardware register base address pointer 13

6.2.7 Function rstc_get_reset_cause() Get the reset cause. uint32_t rstc_get_reset_cause( Rstc * p_rstc) Table 6-7. Parameters Data direction Parameter name Description [in] p_rstc Module hardware register base address pointer Returns The last reset cause. 6.2.8 Function rstc_get_status() Get the RSTC status. uint32_t rstc_get_status( Rstc * p_rstc) Table 6-8. Parameters Data direction Parameter name Description [in] p_rstc Module hardware register base address pointer Returns RSTC status. 6.2.9 Function rstc_reset_extern() Asserts the NRST pin for external resets. void rstc_reset_extern( Rstc * p_rstc) Table 6-9. Parameters Data direction Parameter name Description [out] p_rstc Module hardware register base address pointer 6.2.10 Function rstc_set_external_reset() Set the external reset length. void rstc_set_external_reset( 14

Rstc * p_rstc, const uint32_t ul_length) Table 6-10. Parameters Data direction Parameter name Description [in, out] p_rstc Module hardware register base address pointer [in] ul_length The length of external reset 6.2.11 Function rstc_start_software_reset() Perform a Software Reset. void rstc_start_software_reset( Rstc * p_rstc) Table 6-11. Parameters Data direction Parameter name Description [out] p_rstc Module hardware register base address pointer 15

7. Extra Information for Reset Controller Driver 7.1 Acronyms Below is a table listing the acronyms used in this module, along with their intended meanings. Acronym GND I/O NRST QSG SCLK Definition Ground Input Output Synchronous Microcontroller Reset Quick Start Guide Slow Clock 7.2 Dependencies This driver has the following dependencies: None 7.3 Errata There are no errata related to this driver. 7.4 Module History An overview of the module history is presented in the table below, with details on the enhancements and fixes made to the module since its first release. The current version of this corresponds to the newest version in the table. Changelog Initial document release 16

8. Examples for Reset Controller Driver This is a list of the available Quick Start Guides (QSGs) and example applications for SAM4 Reset Controller (RSTC). QSGs are simple examples with step-by-step instructions to configure and use this driver in a selection of use cases. Note that QSGs can be compiled as a standalone application or be added to the user application. Quick Start guide for SAM RSTC driver Reset Controller (RSTC) Example 8.1 Quick Start guide for SAM RSTC driver This is the quick start guide for the SAM Reset Controller (RSTC) driver, with step-by-step instructions on how to configure and use the driver in a selection of use cases. The use cases contain several code fragments. The code fragments in the steps for setup can be copied into a custom initialization function, while the steps for usage can be copied into, e.g., the main application function. 8.1.1 Basic Use Case In this basic use case, the User Reset interrupt is enabled and the main application notified about NRST signal assertion events. 8.1.1.1 Prerequisites System Clock Management Watchdog Timer 8.1.2 Setup Steps 8.1.2.1 Example Code Add the following to the application C-file: static volatile bool reset_interrupt_triggered = false; void RSTC_Handler(void) { /* Clear the interrupt. */ rstc_get_status(rstc); } reset_interrupt_triggered = true; 8.1.2.2 Workflow Enable the User Reset interrupt: rstc_disable_user_reset(rstc); NVIC_DisableIRQ(RSTC_IRQn); rstc_enable_user_reset_interrupt(rstc); NVIC_ClearPendingIRQ(RSTC_IRQn); NVIC_SetPriority(RSTC_IRQn, 0); NVIC_EnableIRQ(RSTC_IRQn); 8.1.3 Usage Steps 8.1.3.1 Workflow Add to, e.g., main loop in application C-file: 17

if (reset_interrupt_triggered) { /* Critical section to access a variable that is set in an IRQ. */ cpu_irq_enter_critical(); reset_interrupt_triggered = false; cpu_irq_leave_critical(); } puts("user Reset IRQ triggered. Press any console key for the menu\r"); 8.2 Reset Controller (RSTC) Example 8.2.1 Purpose This basic example shows how to use the Reset Controller (RSTC) peripheral available on SAM devices. The RSTC handles all the resets of the system, reports which reset occurred last and also drives independently or simultaneously the external reset and the peripheral and processor resets. 8.2.2 Requirements This example can be used with SAM evaluation kits Optional: An oscilloscope connected to the evaluation kit's NRST signal 8.2.3 Description Upon startup, the program displays the reset controller status and a menu to perform the following: * Menu: * 0 - Reset Status information. * 1 - User Reset enable. * 2 - User Reset disable. * 3 - User Reset interrupt enable. * 4 - User Reset interrupt disable. * 5 - Software Reset. * 6 - Watchdog Reset. * 7 - NRST assert. The menu can be used to initiate several types of reset and to enable/disable the User Reset interrupt. 8.2.4 Main Files rstc.c: Reset Controller driver rstc.h: Reset Controller driver header file rstc_example1.c: Reset Controller example application 8.2.5 Compilation Information 8.2.6 Usage This software is written for GNU GCC and IAR Embedded Workbench for Atmel. Other compilers may or may not work. 1. Build the program and download it into the evaluation board. 18

2. On the computer, open and configure a terminal application (e.g., HyperTerminal on Microsoft Windows ) with these settings: 115200 baud 8 bits of data No parity 1 stop bit No flow control 3. Start the application. 4. In the terminal window, the following text should appear: * -- RSTC Reset Controller Example -- * -- xxxxxx-xx * -- Compiled: xxx xx xxxx xx:xx:xx -- * * Reset info : General Reset, NRST=1, User Reset=0 * * Menu: * 0 - Reset Status information. * 1 - User Reset enable. * 2 - User Reset disable. * 3 - User Reset interrupt enable. * 4 - User Reset interrupt disable. * 5 - Software Reset. * 6 - Watchdog Reset. * 7 - NRST assert. 5. Press one of the keys listed in the menu to perform the corresponding action. Press '1': The following message is displayed: User Reset enabled - Press evaluation kit RESET button to test. If the evaluation kit's reset button is pressed the last reset source will be displayed and the menu shown again. Press '2': The following message is displayed: User Reset enabled - Press evaluation kit RESET button to test. If the evaluation kit's reset button is pressed it will have no effect on the system. Press '3': The following message is displayed: User Reset interrupt enabled.. If the evaluation kit's reset button is pressed the following message will be displayed. User Reset IRQ triggered. Press any console key for the menu Press '4': The following message is displayed: 19

User Reset interrupt disabled. If the evaluation kit's reset button is pressed it will have no effect on the system. Press '5': The following message is displayed: Software Reset activated. The evaluation kit will perform a software reset, the last reset source will be displayed and the menu shown again. Press '6': The following message is displayed: Watchdog Reset will trigger in 3 seconds. The evaluation kit will perform a watchdog reset, the last reset source will be displayed and the menu shown again. Press '7': The following message is displayed: NRST asserted. The evaluation kit will assert the NRST signal for 60μs. Note The "NRST assert" menu option requires an oscilloscope connected to the evaluation kit's NRST signal. To avoid a hardware conflict during the test do not use the evaluation kit's manual RESET button. 20

Index F Function Definitions rstc_assert_reset_of_coprocessor, 12 rstc_deassert_reset_of_coprocessor, 12 rstc_disable_user_reset, 12 rstc_disable_user_reset_interrupt, 13 rstc_enable_user_reset, 13 rstc_enable_user_reset_interrupt, 13 rstc_get_reset_cause, 14 rstc_get_status, 14 rstc_reset_extern, 14 rstc_set_external_reset, 14 rstc_start_software_reset, 15 M Macro Definitions RSTC_BACKUP_RESET, 11 RSTC_CPMR_KEY_PASSWD, 11 RSTC_GENERAL_RESET, 11 RSTC_NRST_HIGH, 11 RSTC_NRST_LOW, 11 RSTC_SOFTWARE_RESET, 11 RSTC_USER_RESET, 11 RSTC_WATCHDOG_RESET, 11 21

Document Revision History Doc. Rev. Date Comments 42279A 05/2014 Initial document release 22

Atmel Corporation 1600 Technology Drive, San Jose, CA 95110 USA T: (+1)(408) 441.0311 F: (+1)(408) 436.4200 www.atmel.com 2014 Atmel Corporation. All rights reserved. / Rev.: Atmel, Atmel logo and combinations thereof, Enabling Unlimited Possibilities, and others are registered trademarks or trademarks of Atmel Corporation or its subsidiaries. Windows is a registered trademark of Microsoft Corporation in U.S. and or other countries. Other terms and product names may be trademarks of others. Disclaimer: The information in this document is provided in connection with Atmel products. No license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by this document or in connection with the sale of Atmel products. EXCEPT AS SET FORTH IN THE ATMEL TERMS AND CONDITIONS OF SALES LOCATED ON THE ATMEL WEBSITE, ATMEL ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDENTAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS AND PROFITS, BUSINESS INTERRUPTION, OR LOSS OF INFORMATION) ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF ATMEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Atmel makes no representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and products descriptions at any time without notice. Atmel does not make any commitment to update the information contained herein. Unless specifically provided otherwise, Atmel products are not suitable for, and shall not be used in, automotive applications. Atmel products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life.