Microchip® Advanced Software Framework

Quick Start Guide for the Peripheral Event Controller Driver

This is the quick start guide for the SAM4L Peripheral Event Controller (PEVC) Driver, with step-by-step instructions on how to configure and use the driver for a specific use case.

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.

Use Cases

Basic Use Case

This use case will demonstrate how to use the Peripheral Event Controller on SAM4L_EK. In this use case, one Event Channel is configured as:

  • Configure AST periodic event 0 as a generator
  • Configure PDCA channel 0 as a user to transfer one word
  • Enable the event shaper for the generator

Setup Steps

Prerequisites

This module requires the following service:

Code Example

Copy-paste the following setup code to your application:

static void init_events(void)
{
struct events_conf events_config;
struct events_ch_conf ch_config;
/* Initialize event module */
events_get_config_defaults(&events_config);
events_init(&events_config);
/*
* Configure an event channel
* - AST periodic event 0 --- Generator
* - PDCA channel 0 --- User
*/
ch_config.channel_id = PEVC_ID_USER_PDCA_0;
ch_config.generator_id = PEVC_ID_GEN_AST_2;
ch_config.shaper_enable = true;
ch_config.igf_edge = EVENT_IGF_EDGE_NONE;
events_ch_configure(&ch_config);
/* Enable the channel */
events_ch_enable(PEVC_ID_USER_PDCA_0);
}

Add this to the main loop or a setup function:

/* Initialize AST as event generator. */
/* Initialise events for this example. */
/* Initialize the PDCA as event user */

Workflow

  1. Initialize AST to generate periodic event 0. see sam/drivers/events/example1 for more detail:
  2. Initialize the event module and enable it:
  3. Initialize PDCA channel 0 to transfer data to USART. see sam/drivers/events/example1 for more detail:

Basic Usage

After the channel is configured correctly and enabled, each time a new event from AST occurs, a character is sent to the USART via PDCA without the use of the CPU.