UDT for PWM modules, containing the functions to drive the hardware. More...
Public Member Functions | |
PwmMod (BYVAL_AS_Pruio__PTR) | |
The constructor for PWM features of the PWMSS. More... | |
FUNCTION_CDECL_AS_ZSTRING_PTR | Value (BYVAL_AS_UInt8, BYVAL_AS_Float_t_PTR, BYVAL_AS_Float_t_PTR) |
Compute PWM output configuration. More... | |
FUNCTION_CDECL_AS_ZSTRING_PTR | setValue (BYVAL_AS_UInt8, BYVAL_AS_Float_t, BYVAL_AS_Float_t) |
Set PWM output on a header pin. More... | |
FUNCTION_CDECL_AS_ZSTRING_PTR | Sync (BYVAL_AS_UInt8) |
Synchronize PWMSS-PWM modules. More... | |
Public Attributes | |
Pruio__PTR | Top |
pointer to the calling PruIo instance | |
UInt16 | ForceUpDown = 0 |
Switch to force up-down counter for ePWM modules. | |
UInt16 | Cntrl [PRUIO_AZ_PWMSS+1] |
Initializers TBCTL register for ePWM modules (see PWM). More... | |
UInt16 | AqCtl [1+1][PRUIO_AZ_PWMSS+1][+1] |
Initializers for Action Qualifier for ePWM modules (see PWM). More... | |
UDT for PWM modules, containing the functions to drive the hardware.
Pulse width modulated (PWM) output can get generated in three ways.
All PWM generators (ePWM-1/2, eCAP and Timer) are controlled by the member functions of this structure (UDT). See ARM Reference Guide, chapter 15 for hardware details.
Definition at line 239 of file pruio_pwmss.bi.
PwmMod::PwmMod | ( | BYVAL_AS_Pruio__PTR | T | ) |
The constructor for PWM features 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 PWM module.
The constructor just copies a pointer to the calling main UDT PruIo.
Definition at line 470 of file pruio_pwmss.bas.
FUNCTION_CDECL_AS_ZSTRING_PTR PwmMod::setValue | ( | BYVAL_AS_UInt8 | Ball, |
BYVAL_AS_Float_t | Hz, | ||
BYVAL_AS_Float_t | Du | ||
) |
Set PWM output on a header pin.
Ball | The CPU ball number. |
Hz | The frequency to set (or -1 for no change). |
Du | The duty cycle to set (0.0 to 1.0, or -1 for no change). |
This function sets PWM output on a header pin. PWM output may either be generated by a eHRPWM or a eCAP module in the PWMSS subsystem, or by one of the TIMER-[4-7] subsystems. Depending on the specified pin number (parameter Ball
), the corresponding PWMSS module or TIMERSS gets configured to the specified frequency and duty cycle.
It's recommended to make the first call to this function before the call to function PruIo::config(), because eCAP pins (P9_28 or P9_42) can be used in PWM output and in CAP input mode. A mode change happens when the configurations gets transfered from the host to the PRU. Also, when an eCAP pin is currently used as input, the new PWM output mode gets active after the next call to function PruIo::config().
Only positive values in the parameters Hz
and Du
force a change. Pass a negative value to stay with the current setting. A duty parameter greater than 1.0 gets limited to 1.0 (= 100%).
In the first call to this function, the parameter Hz
must be greater than 0 (zero), to set a valid period time. In case of eHRPWM modules both outputs A and B of must run at the same frequency, so you need not set the Hz
parameter when you set the Du
parameter for the second output.
The hardware settings (integer values) are computed to match the passed parameters Hz
and Du
as close as possible. Some parameter combinations are impossible to match exactly, due to hardware limitations (ie. 17 bit resolution in case of eHRPWM modules). Use function PwmMod::Value() to compute the active settings, in order to calculate differences.
Wrapper function (C or Python): pruio_pwm_setValue().
Definition at line 564 of file pruio_pwmss.bas.
FUNCTION_CDECL_AS_ZSTRING_PTR PwmMod::Sync | ( | BYVAL_AS_UInt8 | Mask | ) |
Synchronize PWMSS-PWM modules.
Mask | The bit-mask to set |
All clocks of the PWM modules in the PWM sub systems can get enabled or disabled by a single write access to TBCLK register in the controll modules (CM). This feature allows to syncronise PWM signals generated by several modules on different subsystem. The process is
In order to stop a clock, set its bit in the Mask parameter to 0 (zero). Bit 2 is for PWMSS2-PWM, Bit 1 for PWMSS1-PWM and Bit 0 for PWMSS0-PWM module.
Once you configured the modules and uploaded the configuration to the PRUSS (by calling PruIo::config() ) you can start all PWM modules by a further call with their Mask bits set to 1. See ARM Reference Guide, chapter 15.2.2.3.4 for details,
Examples:
.sync(&b000) ' -> stopps all PWM module clocks .sync(&b101) ' -> starts clocks of modules 2 and 0, counters synchonized
Definition at line 648 of file pruio_pwmss.bas.
FUNCTION_CDECL_AS_ZSTRING_PTR PwmMod::Value | ( | BYVAL_AS_UInt8 | Ball, |
BYVAL_AS_Float_t_PTR | Hz = 0 , |
||
BYVAL_AS_Float_t_PTR | Du = 0 |
||
) |
Compute PWM output configuration.
Ball | The pin index. |
Hz | A pointer to output the frequency value (or 0 for no output). |
Du | A pointer to output the duty value (or 0 for no output). |
This functions computes the real PWM output of a header pin. The real setting may differ from the parameters passed to function PwmMod::setValue(). Use this function to compute the active settings.
Wrapper function (C or Python): pruio_pwm_Value().
Definition at line 489 of file pruio_pwmss.bas.
UInt16 PwmMod::AqCtl[1+1][PRUIO_AZ_PWMSS+1][+1] |
Initializers for Action Qualifier for ePWM modules (see PWM).
Definition at line 245 of file pruio_pwmss.bi.
UInt16 PwmMod::Cntrl[PRUIO_AZ_PWMSS+1] |
Initializers TBCTL register for ePWM modules (see PWM).
Definition at line 243 of file pruio_pwmss.bi.