2.19 PTG Driver

Overview

The Peripheral Trigger Generator (PTG) module is a user-programmable sequencer, which is capable of generating complex trigger signal sequences to coordinate the operation of other peripherals. The PTG module is designed to interface with other modules, such as Analog-to-Digital Converter (ADC), output compare and PWM modules, timers and interrupt controllers.

Features Supported

  • Behavior is Step Command-Driven
    • Step commands are 8 bits wide.
    • Commands are Stored in a Step Queue.
  • Programmable Step execution time (Step delay).
  • Hardware Input Triggers
    • Sensitive to either positive or negative edges, or a high or low level.
    • One Software Input Trigger.
  • Generates up to 32 Unique Output Trigger Signals.
  • Generates Two Types of Trigger Outputs
    • Individual.
    • Broadcast.
  • Two 16-Bit General Purpose Timers.
  • Flexible Self-Contained Watchdog Timer (WDT) to Set an Upper Limit to Trigger Wait Time.
  • Clock source and clock divider are user configurable, it is selected from the PLIB.

2.19.1 Module Documentation

2.19.1.1 PTG Driver

Peripheral Trigger Generator Driver is a user-programmable sequencer that is capable of generating complex trigger signal sequences to coordinate the operation of other peripherals using dsPIC MCUs.

2.19.1.1.1 Module description

Peripheral Trigger Generator Driver is a user-programmable sequencer that is capable of generating complex trigger signal sequences to coordinate the operation of other peripherals using dsPIC MCUs.

Data structures
  • struct PTG_INTERFACE

    Structure containing the function pointers of PTG driver.

Functions
  • void PTG_Initialize (void)

    Initializes PTG module.

  • void PTG_Deinitialize (void)

    Deinitializes the PTG to POR values.

  • void PTG_Enable (void)

    Enables the PTG module.

  • void PTG_StepSequenceStart (void)

    Starts the PTG step sequence execution.

  • void PTG_SoftwareTriggerSet (void)

    Sets the software trigger for PTG module.

  • bool PTG_WatchdogTimeoutStatusGet (void)

    Returns the status of PTG watchdog timeout bit.

  • void PTG_StepSequenceStop (void)

    Stops the PTG step sequence execution.

  • void PTG_Disable (void)

    Disables the PTG module.

  • void PTG_EventCallbackRegister (enum PTG_EVENTS event, void(*callback)(void))

    This function can be used to override default callback and to define custom callback for PTG events.

  • void PTG_Trigger0Callback (void)

    This is the default callback with weak attribute. The user can override and implement the default callback without weak attribute or can register a custom callback function using PTG_Trigger0CallbackRegister.

  • void PTG_Trigger1Callback (void)

    This is the default callback with weak attribute. The user can override and implement the default callback without weak attribute or can register a custom callback function using PTG_Trigger1CallbackRegister.

  • void PTG_Trigger2Callback (void)

    This is the default callback with weak attribute. The user can override and implement the default callback without weak attribute or can register a custom callback function using PTG_Trigger2CallbackRegister.

  • void PTG_Trigger3Callback (void)

    This is the default callback with weak attribute. The user can override and implement the default callback without weak attribute or can register a custom callback function using PTG_Trigger3CallbackRegister.

  • void PTG_WatchDogTimerCallback (void)

    This is the default callback with weak attribute. The user can override and implement the default callback without weak attribute or can register a custom callback function using PTG_WatchDogTimerCallbackRegister.

  • void PTG_Tasks (enum PTG_EVENTS event)

    This function is used to implement the tasks for polled implementations.

Variables
  • const struct PTG_INTERFACE PTG

    Structure object of type PTG_INTERFACE with the custom name given by the user in the Melody Driver User interface.

2.19.1.1.2 Function Documentation

PTG_Deinitialize()

void PTG_Deinitialize (void )

Deinitializes the PTG to POR values.

Parameters:
none
Returns:

none

PTG_Disable()

void PTG_Disable (void )

Disables the PTG module.

Parameters:
none
Returns:

none

PTG_Enable()

void PTG_Enable (void )

Enables the PTG module.

Precondition:

PTG_Initialize function should have been called before calling this function.

Parameters:
none
Returns:

none

PTG_EventCallbackRegister()

void PTG_EventCallbackRegister (enum PTG_EVENTS event, void(*)(void) callback)

This function can be used to override default callback and to define custom callback for PTG events.

Parameters:
in event

- PTG events that are available

in callback

- Address of the callback function

Returns:

none

PTG_Initialize()

void PTG_Initialize (void )

Initializes PTG module.

Parameters:
none
Returns:

none

PTG_SoftwareTriggerSet()

void PTG_SoftwareTriggerSet (void )

Sets the software trigger for PTG module.

Parameters:
none
Returns:

none

PTG_StepSequenceStart()

void PTG_StepSequenceStart (void )

Starts the PTG step sequence execution.

Precondition:

PTG_Initialize and PTG_Enable functions should have been called before calling this function.

Parameters:
none
Returns:

none

PTG_StepSequenceStop()

void PTG_StepSequenceStop (void )

Stops the PTG step sequence execution.

Parameters:
none
Returns:

none

PTG_Tasks()

void PTG_Tasks (enum PTG_EVENTS event)

This function is used to implement the tasks for polled implementations.

Precondition:

PTG_Initialize() function should be called before calling this function.

Parameters:
in event

- PTG events that are available

Returns:

none

PTG_Trigger0Callback()

void PTG_Trigger0Callback (void )

This is the default callback with weak attribute. The user can override and implement the default callback without weak attribute or can register a custom callback function using PTG_Trigger0CallbackRegister.

Parameters:
none
Returns:

none

PTG_Trigger1Callback()

void PTG_Trigger1Callback (void )

This is the default callback with weak attribute. The user can override and implement the default callback without weak attribute or can register a custom callback function using PTG_Trigger1CallbackRegister.

Parameters:
none
Returns:

none

PTG_Trigger2Callback()

void PTG_Trigger2Callback (void )

This is the default callback with weak attribute. The user can override and implement the default callback without weak attribute or can register a custom callback function using PTG_Trigger2CallbackRegister.

Parameters:
none
Returns:

none

PTG_Trigger3Callback()

void PTG_Trigger3Callback (void )

This is the default callback with weak attribute. The user can override and implement the default callback without weak attribute or can register a custom callback function using PTG_Trigger3CallbackRegister.

Parameters:
none
Returns:

none

PTG_WatchdogTimeoutStatusGet()

bool PTG_WatchdogTimeoutStatusGet (void )

Returns the status of PTG watchdog timeout bit.

Parameters:
none
Returns:

true - PTG watchdog timeout occurred

false - PTG watchdog timeout not occurred

PTG_WatchDogTimerCallback()

void PTG_WatchDogTimerCallback (void )

This is the default callback with weak attribute. The user can override and implement the default callback without weak attribute or can register a custom callback function using PTG_WatchDogTimerCallbackRegister.

Parameters:
none
Returns:

none

2.19.1.1.3 Enumeration Type Documentation

PTG_EVENTS

enum PTG_EVENTS

Defines the PTG events that are available.

Trigger0

PTG Trigger0 Event

Trigger1

PTG Trigger1 Event

Trigger2

PTG Trigger2 Event

Trigger3

PTG Trigger3 Event

WatchDogTimer

PTG WatchDogTimer Event

2.19.1.1.4 Variable Documentation

PTG

const struct PTG_INTERFACE PTG

Structure object of type PTG_INTERFACE with the custom name given by the user in the Melody Driver User interface.

The default name e.g. PTG can be changed by the user in the PTG user interface.This allows defining a structure with application specific name using the 'Custom Name' field. Application specific name allows the API Portability.

2.19.2 Class Documentation

2.19.2.1 PTG_INTERFACE Struct Reference

Structure containing the function pointers of PTG driver.

2.19.2.1.1 Detailed Description

Structure containing the function pointers of PTG driver.

#include <ptg_interface.h>

Public Attributes

2.19.2.1.2 Member Data Documentation

The documentation for this struct was generated from the following file:

source/

ptg_interface.h

Disable

void(* Disable) (void)

Pointer to PTG_Disable.

Enable

void(* Enable) (void)

Pointer to PTG_Enable.

EventCallbackRegister

void(* EventCallbackRegister) (enum PTG_EVENTS event, void(*callback)(void))

Pointer to PTG_EventCallbackRegister.

Tasks

void(* Tasks) (enum PTG_EVENTS event)

Pointer to PTG_Tasks (Supported only in polling mode)

2.19.3 File Documentation

2.19.3.1 source/ptg.h File Reference

This is the generated driver header file for the PTG driver.

#include <xc.h>
#include <stdint.h>
#include <stdbool.h>
#include "ptg_types.h"
#include "ptg_interface.h"

2.19.3.1.1 Functions

  • void PTG_Initialize (void)

    Initializes PTG module.

  • void PTG_Deinitialize (void)

    Deinitializes the PTG to POR values.

  • void PTG_Enable (void)

    Enables the PTG module.

  • void PTG_StepSequenceStart (void)

    Starts the PTG step sequence execution.

  • void PTG_SoftwareTriggerSet (void)

    Sets the software trigger for PTG module.

  • bool PTG_WatchdogTimeoutStatusGet (void)

    Returns the status of PTG watchdog timeout bit.

  • void PTG_StepSequenceStop (void)

    Stops the PTG step sequence execution.

  • void PTG_Disable (void)

    Disables the PTG module.

  • void PTG_EventCallbackRegister (enum PTG_EVENTS event, void(*callback)(void))

    This function can be used to override default callback and to define custom callback for PTG events.

  • void PTG_Trigger0Callback (void)

    This is the default callback with weak attribute. The user can override and implement the default callback without weak attribute or can register a custom callback function using PTG_Trigger0CallbackRegister.

  • void PTG_Trigger1Callback (void)

    This is the default callback with weak attribute. The user can override and implement the default callback without weak attribute or can register a custom callback function using PTG_Trigger1CallbackRegister.

  • void PTG_Trigger2Callback (void)

    This is the default callback with weak attribute. The user can override and implement the default callback without weak attribute or can register a custom callback function using PTG_Trigger2CallbackRegister.

  • void PTG_Trigger3Callback (void)

    This is the default callback with weak attribute. The user can override and implement the default callback without weak attribute or can register a custom callback function using PTG_Trigger3CallbackRegister.

  • void PTG_WatchDogTimerCallback (void)

    This is the default callback with weak attribute. The user can override and implement the default callback without weak attribute or can register a custom callback function using PTG_WatchDogTimerCallbackRegister.

  • void PTG_Tasks (enum PTG_EVENTS event)

    This function is used to implement the tasks for polled implementations.

2.19.3.1.2 Variables

  • const struct PTG_INTERFACE PTG

    Structure object of type PTG_INTERFACE with the custom name given by the user in the Melody Driver User interface.

2.19.3.1.3 Detailed Description

This is the generated driver header file for the PTG driver.

PTG Generated Driver Header File

2.19.3.2 source/ptg_interface.h File Reference

#include <stdbool.h>
#include "ptg_types.h"

2.19.3.2.1 Data structures

  • struct PTG_INTERFACE

    Structure containing the function pointers of PTG driver.

2.19.3.2.2 Detailed Description

PTG Generated Driver Interface Header File

2.19.3.3 source/ptg_types.h File Reference

This is the generated driver types header file for the PTG driver.

2.19.3.3.2 Detailed Description

This is the generated driver types header file for the PTG driver.

PTG Generated Driver Types Header File