The input capture unit
The input capture unit actor can be used to analyze digital signals and waveforms. It can be used in two modes: Edge counting and time measurement.
The input capture unit can measure signals with an average frequency below 1 MHz (the total time for 100 consecutive edges must be >= 50 uS).
Protocols and actors
Currently one input capture actor is supported: minihil.platform.adapters.inputCapture.AInputCaptureUnit
.
The actors function port supports the following messages
Message | Type | Description |
---|---|---|
startEdgeCounting |
void |
Start counting edges only. Measured durations are discarded |
stopEdgeCounting |
void |
stop edge counting and request results |
startMeasurement |
DInputCaptureMeasurementConfig |
start a precise edge time measurement. The passed output buffer must have enough space for all expected edges |
stopMeasurement |
void |
stop the measurement and request results |
Message | Type | Description |
---|---|---|
measurementStarted |
void |
positive reply to startEdgeCounting and startMeasurement if the measurement/counting was started successfully |
measurementAlreadyRunning |
void |
reply if a measurement/counting is running when a startMeasurement or startEdgeCounting message is received |
noActiveMeasurement |
void |
reply if stopMeasurement or stopEdgeCounting are received while no measurement/counting was active |
measurementStopped |
DInputCaptureMeasurementResult |
Reply to stopMeasurement |
edgeCountStopped |
DEdgeCountResult |
Reply to stopEdgeCounting |
bufferOverflow |
void |
Output buffer overflow. Measurement aborted |
internalBufferOverflow |
void |
Internal buffer overflow. Measurement aborted |
Actor documentation
This actor uses a timer + dma to measure the time passed during edges on the input pin.
Have a look at the fct ports protocol (PInputCaptureUnitCtrl) for usage details
The maximum input frequency should be < 1 MHz to avoid buffer overflows
Input: PA0
Used resources: DMA2_Stream4 TIM2
Structure
Name | Protocol | Type | Kind | Multiplicity | Description |
---|---|---|---|---|---|
triggerAnalysisEvt |
PInterrupt |
conjugated |
internal |
1 |
|
internalCfg |
PInputCaptureInternalCfg |
conjugated |
internal |
1 |
|
fct |
PInputCaptureUnitCtrl |
regular |
relay |
1 |
Behavior
- Top Level State
-
- done
-
(no description)
Edge counting mode
Edge counting can be started when no other measurement is currently active. To start counting edges send a startEdgeCounting()
message. The edge counting measurement is only started if the reply is a measurementStarted()
message. If any other message is replied no measurement has been started.
A total edge count (split by rising and falling edges) is returned after a stopEdgeCounting()
is received.
During edge counting mode no external buffers are used. The maximum number of edges counted is limited by uint32 max (for falling and rising edges each). If no edge is detected for more than 2100 seconds an internal timeout buffer will overflow and the measurement will be aborted.
Time measurement mode
Waveform time measurement can be started when no other measurement is currently active. To start a measurement send a startMeasurement(DInputCaptureMeasurementConfig)
message. The measurement is only started if the reply is a measurementStarted()
message.
An output buffer with elements of type EdgeTime
must be provided in the passed measurement config (DInputCaptureMeasurementConfig). The EdgeTime
type is defined in minihil/InputCapture.h
in the SimModelLib.
Data class to configure an edge time measurement
Name | Type | Description |
---|---|---|
outputBuffer |
EdgeTime |
The output buffer in which the timing data are to be saved. Elements should be of type EdgeTime. E.g. EdgeTime outBuffer[500]; bufferLen_entries should be the number of entries in the output buffer. E.g. sizeof(outputBuffer)/sizeof(EdgeTime) |
bufferLen_entries |
uint32 |
CaGe example: Time measurement mode
targetcode:
``
#include "minihil/InputCapture.h"
// includes or defines
static EdgeTime icuOutputBuffer[800];
``
;
// NOTE: The icu port is of type conjugated PInputCaptureUnitCtrl
Step testWaveform:
timeout ... s
action
``
DInputCaptureMeasurementConfig cfg;
cfg.outputBuffer = icuOutputBuffer;
cfg.bufferLen_entries = sizeof(icuOutputBuffer) / sizeof(icuOutputBuffer[0]);
``
icu.startMeasurement(``&cfg``)
reaction
expect icu.measurementStarted
action
// trigger your waveform
reaction
// .. wait for your wave form to end
action
icu.stopMeasurement
reaction
icu.measurementStopped => [data |
expect ``data.risingEdgesCount`` == 2
expect ``data.fallingEdgesCount`` == 2
expect ``data.outputBuffer[0].type == EdgeType_RISING``
expect ``data.outputBuffer[1].type == EdgeType_FALLING``
expect ``data.outputBuffer[2].type == EdgeType_RISING``
expect ``data.outputBuffer[3].type == EdgeType_FALLING``
expect ``data.outputBuffer[1].timeOffset`` in range [0.002..0.003] // first falling edge
expect ``data.outputBuffer[2].timeOffset`` in range [0.003..0.004] // second rising edge
expect ``data.outputBuffer[3].timeOffset`` in range [0.008..0.009] // second falling edge
]
;