3.21 SMT - Signal Measurement Timer
3.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.
3.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 |
3.21.3 Required Header Files:
#include "mcc_generated_files/smt/smt[X].h"
3.21.4 Module Documentation
3.21.4.1 SMTx
This file contains the API prototypes for the SMT module.
3.21.4.1.1 Module description
This file contains the API prototypes for the SMT module.
Functions
void SMTx_Initialize (void)
Initializes the SMT module. This routine is called only once during system initialization, before calling other APIs.
void SMTx_DataAcquisitionEnable (void)
Starts the SMT counter, enabling data acquisition.
void SMTx_DataAcquisitionDisable (void)
Stops the SMT counter, disabling data acquisition.
void SMTx_HaltCounter (void)
Stops the counter at SMTxPR, when SMTxTMR is equal to SMTxPR.
void SMTx_SetPeriod (uint32_t periodVal)
Writes to the SMTx Period registers.
uint32_t SMTx_GetPeriod (void)
Returns the SMTx Period register value.
void SMTx_SingleDataAcquisition (void)
Enables Single Data Acquisition mode.
void SMTx_RepeatDataAcquisition (void)
Enables Repeat Data Acquisition mode.
void SMTx_ManualPeriodBufferUpdate (void)
Requests a write of the SMTx Timer register value to the Captured Period register.
void SMTx_ManualPulseWidthBufferUpdate (void)
Requests a write of the SMTx Timer register value to the Captured Pulse-Width register.
void SMTx_ManualTimerReset (void)
Requests a Reset of the SMTx Timer registers.
bool SMTx_IsWindowOpen (void)
Determines if the SMTx window is open or closed. This function is valid only when SMTx_IsTimerIncrementing() returns True.
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.
bool SMTx_IsTimerIncrementing (void)
Determines if the SMTx timer is incrementing or not.
uint32_t SMTx_GetCapturedPulseWidth (void)
Returns the SMTx Captured Pulse-Width register value.
uint32_t SMTx_GetCapturedPeriod (void)
Returns the SMTx Captured Period register value.
uint32_t SMTx_GetTimerValue (void)
Returns the SMTx Timer register value.
void SMTx_PR_ACQ_ISR (void)
Implements the Period Acquisition Interrupt Service Routine (ISR).
void SMTx_PW_ACQ_ISR (void)
Implements the Pulse-Width Acquisition ISR.
void SMTx_Overflow_ISR (void)
Implements the Counter Overflow ISR.
3.21.4.1.2 Function Documentation
SMTx_DataAcquisitionDisable()
void SMTx_DataAcquisitionDisable (void )
Stops the SMT counter, disabling data acquisition.
Call SMTx_Initialize() at least once before calling this function. |
|
None. |
SMTx_DataAcquisitionEnable()
void SMTx_DataAcquisitionEnable (void )
Starts the SMT counter, enabling data acquisition.
Call SMTx_Initialize() at least once before calling this function. |
|
None. |
SMTx_GetCapturedPeriod()
uint32_t SMTx_GetCapturedPeriod (void )
Returns the SMTx Captured Period register value.
Call SMTx_Initialize() at least once before calling this function. |
|
Captured Period register value. |
SMTx_GetCapturedPulseWidth()
uint32_t SMTx_GetCapturedPulseWidth (void )
Returns the SMTx Captured Pulse-Width register value.
Call SMTx_Initialize() at least once before calling this function. |
|
Captured Pulse-Width register value. |
SMTx_GetPeriod()
uint32_t SMTx_GetPeriod (void )
Returns the SMTx Period register value.
Call SMTx_Initialize() at least once before calling this function. |
|
Period register value. |
SMTx_GetTimerValue()
uint32_t SMTx_GetTimerValue (void )
Returns the SMTx Timer register value.
Call SMTx_Initialize() at least once before calling this function. |
|
Timer register value. |
SMTx_HaltCounter()
void SMTx_HaltCounter (void )
Stops the counter at SMTxPR, when SMTxTMR is equal to SMTxPR.
Call SMTx_Initialize() at least once before calling this function. |
|
None. |
SMTx_Initialize()
void SMTx_Initialize (void )
Initializes the SMT module. This routine is called only once during system initialization, before calling other APIs.
|
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.
Call SMTx_Initialize() and SMTx_DataAcquisitionEnable() at least once before calling this function. |
|
|
SMTx_IsTimerIncrementing()
bool SMTx_IsTimerIncrementing (void )
Determines if the SMTx timer is incrementing or not.
Call SMTx_Initialize() and SMTx_DataAcquisitionEnable() at least once before calling this function. |
|
|
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.
Call SMTx_Initialize() and SMTx_DataAcquisitionEnable() at least once before calling this function. |
|
|
SMTx_ManualPeriodBufferUpdate()
void SMTx_ManualPeriodBufferUpdate (void )
Requests a write of the SMTx Timer register value to the Captured Period register.
Call SMTx_Initialize() and SMTx_DataAcquisitionEnable() at least once before calling this function. |
|
None. |
SMTx_ManualPulseWidthBufferUpdate()
void SMTx_ManualPulseWidthBufferUpdate (void )
Requests a write of the SMTx Timer register value to the Captured Pulse-Width register.
Call SMTx_Initialize() and SMTx_DataAcquisitionEnable() at least once before calling this function. |
|
None. |
SMTx_ManualTimerReset()
void SMTx_ManualTimerReset (void )
Requests a Reset of the SMTx Timer registers.
Call SMTx_Initialize() and SMTx_DataAcquisitionEnable() at least once before calling this function. |
|
None. |
SMTx_Overflow_ISR()
void SMTx_Overflow_ISR (void )
Implements the Counter Overflow ISR.
Initialize SMTx and enable the counter overflow interrupt. |
|
None. |
SMTx_PR_ACQ_ISR()
void SMTx_PR_ACQ_ISR (void )
Implements the Period Acquisition Interrupt Service Routine (ISR).
Initialize SMTx and enable the period acquisition interrupt. |
|
None. |
SMTx_PW_ACQ_ISR()
void SMTx_PW_ACQ_ISR (void )
Implements the Pulse-Width Acquisition ISR.
Initialize SMTx and enable the pulse-width acquisition interrupt. |
|
None. |
SMTx_RepeatDataAcquisition()
void SMTx_RepeatDataAcquisition (void )
Enables Repeat Data Acquisition mode.
Call SMTx_Initialize() and SMTx_DataAcquisitionEnable() at least once before calling this function. |
|
None. |
SMTx_SetPeriod()
void SMTx_SetPeriod (uint32_t periodVal)
Writes to the SMTx Period registers.
Call SMTx_Initialize() at least once before calling this function. |
|
None. |
SMTx_SingleDataAcquisition()
void SMTx_SingleDataAcquisition (void )
Enables Single Data Acquisition mode.
Call SMTx_Initialize() and SMTx_DataAcquisitionEnable() at least once before calling this function. |
|
None. |
3.21.5 File Documentation
3.21.5.1 source/smtx.c File Reference
This file contains the API implementation for the SMTx module.
#include <xc.h> #include "../smtx.h"
3.21.5.1.1 Functions
void SMTx_Initialize (void)
Initializes the SMT module. This routine is called only once during system initialization, before calling other APIs.
void SMTx_DataAcquisitionEnable (void)
Starts the SMT counter, enabling data acquisition.
void SMTx_DataAcquisitionDisable (void)
Stops the SMT counter, disabling data acquisition.
void SMTx_HaltCounter (void)
Stops the counter at SMTxPR, when SMTxTMR is equal to SMTxPR.
void SMTx_SetPeriod (uint32_t periodVal)
Writes to the SMTx Period registers.
uint32_t SMTx_GetPeriod (void)
Returns the SMTx Period register value.
void SMTx_SingleDataAcquisition (void)
Enables Single Data Acquisition mode.
void SMTx_RepeatDataAcquisition (void)
Enables Repeat Data Acquisition mode.
void SMTx_ManualPeriodBufferUpdate (void)
Requests a write of the SMTx Timer register value to the Captured Period register.
void SMTx_ManualPulseWidthBufferUpdate (void)
Requests a write of the SMTx Timer register value to the Captured Pulse-Width register.
void SMTx_ManualTimerReset (void)
Requests a Reset of the SMTx Timer registers.
bool SMTx_IsWindowOpen (void)
Determines if the SMTx window is open or closed. This function is valid only when SMTx_IsTimerIncrementing() returns True.
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.
bool SMTx_IsTimerIncrementing (void)
Determines if the SMTx timer is incrementing or not.
uint32_t SMTx_GetCapturedPulseWidth (void)
Returns the SMTx Captured Pulse-Width register value.
uint32_t SMTx_GetCapturedPeriod (void)
Returns the SMTx Captured Period register value.
uint32_t SMTx_GetTimerValue (void)
Returns the SMTx Timer register value.
void SMTx_PR_ACQ_ISR (void)
Implements the Period Acquisition Interrupt Service Routine (ISR).
void SMTx_PW_ACQ_ISR (void)
Implements the Pulse-Width Acquisition ISR.
void SMTx_Overflow_ISR (void)
Implements the Counter Overflow ISR.
3.21.5.1.2 Detailed Description
This file contains the API implementation for the SMTx module.
SMT1 Generated Driver File.
3.21.5.2 source/smtx.h File Reference
#include <stdbool.h> #include <stdint.h>
3.21.5.2.1 Functions
void SMTx_Initialize (void)
Initializes the SMT module. This routine is called only once during system initialization, before calling other APIs.
void SMTx_DataAcquisitionEnable (void)
Starts the SMT counter, enabling data acquisition.
void SMTx_DataAcquisitionDisable (void)
Stops the SMT counter, disabling data acquisition.
void SMTx_HaltCounter (void)
Stops the counter at SMTxPR, when SMTxTMR is equal to SMTxPR.
void SMTx_SetPeriod (uint32_t periodVal)
Writes to the SMTx Period registers.
uint32_t SMTx_GetPeriod (void)
Returns the SMTx Period register value.
void SMTx_SingleDataAcquisition (void)
Enables Single Data Acquisition mode.
void SMTx_RepeatDataAcquisition (void)
Enables Repeat Data Acquisition mode.
void SMTx_ManualPeriodBufferUpdate (void)
Requests a write of the SMTx Timer register value to the Captured Period register.
void SMTx_ManualPulseWidthBufferUpdate (void)
Requests a write of the SMTx Timer register value to the Captured Pulse-Width register.
void SMTx_ManualTimerReset (void)
Requests a Reset of the SMTx Timer registers.
bool SMTx_IsWindowOpen (void)
Determines if the SMTx window is open or closed. This function is valid only when SMTx_IsTimerIncrementing() returns True.
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.
bool SMTx_IsTimerIncrementing (void)
Determines if the SMTx timer is incrementing or not.
uint32_t SMTx_GetCapturedPulseWidth (void)
Returns the SMTx Captured Pulse-Width register value.
uint32_t SMTx_GetCapturedPeriod (void)
Returns the SMTx Captured Period register value.
uint32_t SMTx_GetTimerValue (void)
Returns the SMTx Timer register value.
void SMTx_PR_ACQ_ISR (void)
Implements the Period Acquisition Interrupt Service Routine (ISR).
void SMTx_PW_ACQ_ISR (void)
Implements the Pulse-Width Acquisition ISR.
void SMTx_Overflow_ISR (void)
Implements the Counter Overflow ISR.
3.21.5.2.2 Detailed Description
SMTx Generated Driver API Header File.