Event System

The XMEGA event system is an inter-peripheral hardware communication network enabling peripherals to directly signal each other without using the CPU. Traditionally, an interrupt with an interrupt service routine would be used when a peripheral needs to trigger an action in another peripheral. However, the event system peripherals can directly trigger an action (event) in other peripherals via the event system. The CPU can be put in Idle sleep mode because the event system operates totally independent from the CPU.

ATxmega128A1U has eight independent event channels. In this application, event channel 7 is used to trigger a conversion on Channel 0 of the ADCA module. The trigger source used for channel 7 will be the RTC overflow flag.

By using the event system, the MCU does not need to wake up from sleep mode to execute Interrupt Servicing Routines (when executing ISR the CPU needs to be in active mode). Therefore, the event system can help you to save power by reducing the amount of time the CPU needs to stay in active mode.

Note that although the extra power consumption used by the event system is very small, it still adds a little bit to the total power consumption. So in applications where the interrupts do not happen very frequently or the interrupt functions are relatively short, the total reduction in current consumption by using the event system will be smaller than in applications where there are frequently occurring interrupts, or interrupts with long execution time.

In this application the event system removes 64 relatively short RTC interrupt routine calls per program cycle, and give us approximately 1% lower power consumption by using the event system. In other applications where many interrupts or longer interrupt servicing routines can be removed, the reduction in power consumption could be even larger. In addition, using the event system will reduce the CPU workload, freeing the CPU for other tasks, and thus increasing your total system performance. It may also allow you to operate the system at a lower frequency and thus saving power.

Here are the event system initialization codes:

// Enable event system clock domain
PR.PRGEN &= ~PR_EVSYS_bm;
// Configure event channel 7 source (RTC overflow)
EVSYS.CH7MUX = EVSYS_CHMUX_RTC_OVF_gc

Below line configures the trigger source of ADC to use RTC overflow event:

//Enable event system
ADCA.EVCTRL |= ADC_SWEEP_0_gc | ADC_EVACT_CH0_gc |ADC_EVSEL_7_gc;