This driver provides API functions to configure and use the Event Generator.
The functions and other declarations used in this driver are in cy_evtgen.h. You can include cy_pdl.h to get access to all functions and declarations in the PDL.
The Event Generator (EVTGEN) implements event generation - in Active mode, for interrupts and triggers and in Deep Sleep mode only for interrupts. The Active functionality interrupt is connected to the CPU interrupt controller. Active mode triggered events can be used to trigger a specific device functionality mode (for example, execution of an interrupt handler, a SAR ADC conversion, and so on) in Active power mode. The Deep Sleep functionality interrupts can be used to wake up the CPU from the Deep Sleep power mode. The event generator includes a single counter and a maximum of 16 comparator structures for each Active and Deep Sleep mode. EVTGEN reduces CPU involvement and thus overall power consumption and jitters.
EVTGEN consists of two blocks: Active and Deep Sleep mode blocks. There are 16 comparator structures and one 32-bit counter for each of the modes which increment with each cycle CLK_REF. Each comparator structure has an Active and a Deep Sleep comparator. A comparator compares a programmed comparator value with the current counter value. When the counter value "passes" (equal) a comparator value, a comparator output is activated.
The Event Generator implements synchronization between the Active counter and Deep Sleep counter through ratio control. The ratio value shows the number of clk_ref_div periods in one clk_lf periods. Event Generator uses Ratio value to synchronize active counter and Deep Sleep counter with hardware automatically.
The EVTGEN driver configuration can be divided into a number of sequential steps:
To set up the EVTGEN driver, provide the configuration parameters in the cy_stc_evtgen_config_t structure. To initialize the driver, call the Cy_EvtGen_Init function providing a pointer to the populated cy_stc_evtgen_config_t structure.
A clock source must be connected to the EVTGEN block to control time. Enable High Frequency clock. Use the SysClk (System Clock) driver API to do.
To set up the Comparator Structure of the EVTGEN driver, provide the configuration parameters in the cy_stc_evtgen_struct_config_t structure. To initialize the Comparator Structure, call the Cy_EvtGen_InitStruct function providing a pointer to the populated cy_stc_evtgen_struct_config_t structure.
The interrupt is the main operation of EVTGEN. Use it to configure an interrupt and create the interrupt handle for the selected EVTGEN instance. Also, enable this interrupt in the NVIC.
Finally, enable the EVTGEN operation by calling Cy_EvtGen_Enable.
Version | Changes | Reason for Change |
---|---|---|
1.0 | Initial version |
API Reference | |
Macro | |
Functions | |
Data structures | |
Enumerated types | |