UDT for PWMSS-CAP modules, containing the functions to drive the hardware. More...
Public Member Functions | |
CapMod (BYVAL_AS_Pruio__PTR) | |
Curr = DRam[2]. More... | |
FUNCTION_CDECL_AS_ZSTRING_PTR | config (BYVAL_AS_UInt8, BYVAL_AS_Float_t) |
Configure a header pin as eCAP input. More... | |
FUNCTION_CDECL_AS_ZSTRING_PTR | Value (BYVAL_AS_UInt8, BYVAL_AS_Float_t_PTR, BYVAL_AS_Float_t_PTR) |
Analyse a digital pulse train, get frequency and duty cycle. More... | |
Public Attributes | |
Pruio__PTR | Top |
pointer to the calling PruIo instance | |
UDT for PWMSS-CAP modules, containing the functions to drive the hardware.
This structure contains the functions to drive the hardware of the eCAP modul in the PWMSS subsystems in input mode.
See ARM Reference Guide, chapter 15.3 for hardware details.
Definition at line 276 of file pruio_pwmss.bi.
CapMod::CapMod | ( | BYVAL_AS_Pruio__PTR | T | ) |
Curr = DRam[2].
The constructor for the CAP feature of the PWMSS.
T | A pointer of the calling PruIo structure. |
Each of the three Pulse Width Modulation SubSystems (PWMSS) in the CPU contains modules (PWM, CAP and QEP). In order to create a clear API from the user point of view, the functions to control the modules are separated to extra classes. This UDT contains functions to control the CAP module, which is used to analyse the frequency and duty cycle of a digital pulse train.
The constructor just copies a pointer to the calling main UDT PruIo.
Definition at line 690 of file pruio_pwmss.bas.
FUNCTION_CDECL_AS_ZSTRING_PTR CapMod::config | ( | BYVAL_AS_UInt8 | Ball, |
BYVAL_AS_Float_t | FLow = 0. |
||
) |
Configure a header pin as eCAP input.
Ball | The CPU ball number to configure. |
FLow | Minimal frequency to measure in Hz (> .0232831). |
This function configures a header pin for Capture and Analyse Pulse (CAP) trains. The pins configuration gets checked. If it's not configured as input for the CAP module in the PWMSS subsystem, libpruio tries to adapt the pinmuxing. This fails if the program isn't executed with admin privileges.
Currently CAP is available on pins P9_42, P9_28 and SD_10.
The parameter FLow
specifies the minimal frequency to measure in Hz. When not set (values < .0232831) and the input doesn't change, the counter runs until an overflow before it returns the new values (in this case frequency = 0 and duty cycle = 0). This lasts about 43 seconds before the new values are available. To shorten this time, you can specify the lowest frequency. When a period without change is over, the counter gets restarted.
Wrapper function (C or Python): pruio_cap_config().
Definition at line 720 of file pruio_pwmss.bas.
FUNCTION_CDECL_AS_ZSTRING_PTR CapMod::Value | ( | BYVAL_AS_UInt8 | Ball, |
BYVAL_AS_Float_t_PTR | Hz = 0 , |
||
BYVAL_AS_Float_t_PTR | Du = 0 |
||
) |
Analyse a digital pulse train, get frequency and duty cycle.
Ball | The CPU ball number to test. |
Hz | A pointer to store the frequency value (or null). |
Du | A pointer to store the duty cycle value (or null). |
This function returns the frequency and duty cycle of a digital pulse train on a header pin. The header pin needs to get configured first by a call to function CapMod::config().
The parameters Hz
and Du
contain the results of the last measured period. You can pass a zero pointer to either of them if you don't need this value.
A period is limited by the counter resolution. The minimal frequency is 0.0232831 Hz, so a period lasts maximal 43 seconds. When the state of the input pin doesn't change twice during a period, the counter restarts and zero gets returned for both results (Hz
and Du
). The minimal frequency can get adapted by parameter FLow
in the previous call to function CapMod::config().
Wrapper function (C or Python): pruio_cap_Value().
Definition at line 788 of file pruio_pwmss.bas.