3 Introduction to Event System

The Event System (EVSYS) is a typical CIP, which allows a change in one peripheral (the event generator) to trigger actions in other peripherals (the event users) through event channels. It is a simple but powerful system as it allows for autonomous control of peripherals without any use of interrupts, CPU, or DMA resources. It provides short and predictable response times between peripherals, and can reduce the complexity, size, and execution time of the software, and save power.

AVR usually supports several parallel event channels, and one event channel can be divided into three distinct parts:
  • Event generators, with one or more event sources
  • The event routing network
  • Event users

An event is an indication that a change of state within a peripheral has occurred. A peripheral capable of generating events is called an event generator. One event generator may be able to generate events on several changes within the peripheral. Each of these is an individual event source. A channel can be either asynchronous or synchronous to the main clock, based on the requirements of the application. For the tinyAVR® 1-Series, there are four asynchronous and two synchronous event channels. Register ASYNCH0, ASYNCH1, ASYNCH2, ASYNCH3, SYCNCH0, and SYNCH1 are used to configure event sources for these channels accordingly. Only one trigger from an event generator peripheral can be routed on each event channel, but multiple channels can use the same generator source. Multiple peripherals can use events from the same channel.

The event routing network handles the routing of events from the event generator to the event user. Every event source from every event generator is connected to the inputs of each of the event channels. An event user is a peripheral module that can make use of an event to trigger an action, referred to as an event action. An event user selects the event source to react to by selecting an event channel. The actual event source is determined by the multiplier setting in the selected event channel.

The Event System can directly connect analog and digital converters, analog comparators, I/O port pins, real-time counters, timer/counters, and the configurable custom logic peripherals. Events can also be generated from software and the peripheral clock.

The following figure shows a simplified version with one timer/counter as event generator and one ADC as an event user. The event channel MUX's can select one of three available sources to be routed through the corresponding event channel.

Figure 3-1. Example of Event Source, Generator, User, and Action

The Event System uses the peripheral clock for I/O registers and strobes. Also, it can be used in Sleep modes without any clock. An event usually lasts for one clock cycle.

Manual Event Generation: It is possible to generate events either from software or by using the on-chip debugging system. The generated events are injected directly in the event channels. The event channel does not need to have an event source associated with it to use the manual event generation possibilities. If an event source is associated with the event channel, the manually generated event has priority and will override the peripheral event. Two registers are used for manual event generation: STROBE and DATA. The event generation is triggered by a write to the STROBE register. When generating signaling events, only the STROBE register is needed. When generating data events, both STROBE and DATA must be used and STROBE must be written after DATA.

Events and Sleep modes: The Event System is operative in Active mode and Standby Sleep mode. In all other Sleep modes, peripheral modules will not be able to communicate using the Event System.