4.21 SMT - Signal Measurement Timer

4.21.1 Introduction

The MPLAB® Code Configurator (MCC) Melody Signal Measurement Timer Peripheral Library (PLIBs) drivers generates APIs to support SMT-specific peripheral functionality on target MCUs.

The Signal Measurement Timer (SMT) is a 24-bit counter with advanced clock and gating logic, which can be configured for measuring a variety of digital signal parameters such as pulse width, frequency and duty cycle, and the time difference between edges on two signals.

4.21.2 Supported Device Families

PIC12/16F161x PIC12/16F184x PIC16F184xx
PIC16F188xx PIC16F191xx PIC18F-K40
PIC18F-K42 PIC18F-K83 PIC18F-Q40
PIC18F-Q41 PIC18F-Q43 PIC18F-Q83
PIC18F-Q84

4.21.3 Required Header Files:

#include "mcc_generated_files/smt/smt[X].h"
Note: Replace [X] with the instance number of the selected SMT module.

4.21.4 Module Documentation

4.21.4.1 SMTx

This file contains the API prototypes for the SMT module.

4.21.4.1.1 Module description

This file contains the API prototypes for the SMT module.

Version: SMT Driver Version 2.11
Functions

4.21.4.1.2 Function Documentation

SMTx_DataAcquisitionDisable()

void SMTx_DataAcquisitionDisable (void )

Stops the SMT counter, disabling data acquisition.

Precondition:

Call SMTx_Initialize() at least once before calling this function.

Parameters:
None.
Returns:

None.

SMTx_DataAcquisitionEnable()

void SMTx_DataAcquisitionEnable (void )

Starts the SMT counter, enabling data acquisition.

Precondition:

Call SMTx_Initialize() at least once before calling this function.

Parameters:
None.
Returns:

None.

SMTx_GetCapturedPeriod()

uint32_t SMTx_GetCapturedPeriod (void )

Returns the SMTx Captured Period register value.

Precondition:

Call SMTx_Initialize() at least once before calling this function.

Parameters:
None.
Returns:

Captured Period register value.

SMTx_GetCapturedPulseWidth()

uint32_t SMTx_GetCapturedPulseWidth (void )

Returns the SMTx Captured Pulse-Width register value.

Precondition:

Call SMTx_Initialize() at least once before calling this function.

Parameters:
None.
Returns:

Captured Pulse-Width register value.

SMTx_GetPeriod()

uint32_t SMTx_GetPeriod (void )

Returns the SMTx Period register value.

Precondition:

Call SMTx_Initialize() at least once before calling this function.

Parameters:
None.
Returns:

Period register value.

SMTx_GetTimerValue()

uint32_t SMTx_GetTimerValue (void )

Returns the SMTx Timer register value.

Precondition:

Call SMTx_Initialize() at least once before calling this function.

Parameters:
None.
Returns:

Timer register value.

SMTx_HaltCounter()

void SMTx_HaltCounter (void )

Stops the counter at SMTxPR, when SMTxTMR is equal to SMTxPR.

Precondition:

Call SMTx_Initialize() at least once before calling this function.

Parameters:
None.
Returns:

None.

SMTx_Initialize()

void SMTx_Initialize (void )

Initializes the SMT module. This routine is called only once during system initialization, before calling other APIs.

Parameters:
None.
Returns:

None.

SMTx_IsSignalAcquisitionInProgress()

bool SMTx_IsSignalAcquisitionInProgress (void )

Determines if the SMTx signal acquisition is in progress or not. This function is valid only when SMTx_IsTimerIncrementing() returns True.

Precondition:

Call SMTx_Initialize() and SMTx_DataAcquisitionEnable() at least once before calling this function.

Parameters:
None.
Return values:
True

- SMTx signal acquisition is in progress.

False

- SMTx signal acquisition is not in progress.

SMTx_IsTimerIncrementing()

bool SMTx_IsTimerIncrementing (void )

Determines if the SMTx timer is incrementing or not.

Precondition:

Call SMTx_Initialize() and SMTx_DataAcquisitionEnable() at least once before calling this function.

Parameters:
None.
Return values:
True

- SMTx timer is incrementing.

False

- SMTx timer is not incrementing.

SMTx_IsWindowOpen()

bool SMTx_IsWindowOpen (void )

Determines if the SMTx window is open or closed. This function is valid only when SMTx_IsTimerIncrementing() returns True.

Precondition:

Call SMTx_Initialize() and SMTx_DataAcquisitionEnable() at least once before calling this function.

Parameters:
None.
Return values:
True

- SMTx window is open.

False

- SMTx window is closed.

SMTx_ManualPeriodBufferUpdate()

void SMTx_ManualPeriodBufferUpdate (void )

Requests a write of the SMTx Timer register value to the Captured Period register.

Precondition:

Call SMTx_Initialize() and SMTx_DataAcquisitionEnable() at least once before calling this function.

Parameters:
None.
Returns:

None.

SMTx_ManualPulseWidthBufferUpdate()

void SMTx_ManualPulseWidthBufferUpdate (void )

Requests a write of the SMTx Timer register value to the Captured Pulse-Width register.

Precondition:

Call SMTx_Initialize() and SMTx_DataAcquisitionEnable() at least once before calling this function.

Parameters:
None.
Returns:

None.

SMTx_ManualTimerReset()

void SMTx_ManualTimerReset (void )

Requests a Reset of the SMTx Timer registers.

Precondition:

Call SMTx_Initialize() and SMTx_DataAcquisitionEnable() at least once before calling this function.

Parameters:
None.
Returns:

None.

SMTx_Overflow_ISR()

void SMTx_Overflow_ISR (void )

Implements the Counter Overflow ISR.

Precondition:

Initialize SMTx and enable the counter overflow interrupt.

Parameters:
None.
Returns:

None.

SMTx_PR_ACQ_ISR()

void SMTx_PR_ACQ_ISR (void )

Implements the Period Acquisition Interrupt Service Routine (ISR).

Precondition:

Initialize SMTx and enable the period acquisition interrupt.

Parameters:
None.
Returns:

None.

SMTx_PW_ACQ_ISR()

void SMTx_PW_ACQ_ISR (void )

Implements the Pulse-Width Acquisition ISR.

Precondition:

Initialize SMTx and enable the pulse-width acquisition interrupt.

Parameters:
None.
Returns:

None.

SMTx_RepeatDataAcquisition()

void SMTx_RepeatDataAcquisition (void )

Enables Repeat Data Acquisition mode.

Precondition:

Call SMTx_Initialize() and SMTx_DataAcquisitionEnable() at least once before calling this function.

Parameters:
None.
Returns:

None.

SMTx_SetPeriod()

void SMTx_SetPeriod (uint32_t periodVal)

Writes to the SMTx Period registers.

Precondition:

Call SMTx_Initialize() at least once before calling this function.

Parameters:
uint32_t

periodVal - Period value to be loaded.

Returns:

None.

SMTx_SingleDataAcquisition()

void SMTx_SingleDataAcquisition (void )

Enables Single Data Acquisition mode.

Precondition:

Call SMTx_Initialize() and SMTx_DataAcquisitionEnable() at least once before calling this function.

Parameters:
None.
Returns:

None.

4.21.5 File Documentation

4.21.5.1 source/smtx.c File Reference

This file contains the API implementation for the SMTx module.

#include <xc.h>
#include "../smtx.h"

4.21.5.1.1 Functions

4.21.5.1.2 Detailed Description

This file contains the API implementation for the SMTx module.

SMT1 Generated Driver File.

Version: SMTx Driver Version 2.11

4.21.5.2 source/smtx.h File Reference

#include <stdbool.h>
#include <stdint.h>

4.21.5.2.1 Functions

4.21.5.2.2 Detailed Description

SMTx Generated Driver API Header File.