|
COX PWM Peripheral Interface
Version: 1.00 - 26. June 2010
Contents
Overview
The Pulse Width Modulator (PWM) peripheral is used to control the frequency and mark-space ratio of a digital pulse train. The PWM duty cycle is the pulse duration divided by the pulse period. For a pulse train in which the pulse duration is 1 μs and the pulse period is 4 μs, the duty cycle is 0.25. The duty cycle of a square wave is 0.5, or 50%.
Interface Definition
PWM Interface Definition : COX PWM Interface is a structure variable of COX_PWM_PI type, it contains a list of pointers to the functions that implement the standard functions specified by COX. Use different variables to access different PWM peripherals.
| Serial Interface |
typedef struct {
COX_Status (*Init) (void);
COX_Status (*Period) (uint16_t pwmout, float period);
COX_Status (*Width) (uint16_t pwmout, float width);
COX_Status (*usPeriod) (uint16_t pwmout, uint32_t period);
COX_Status (*usWidth) (uint16_t pwmout, uint32_t width);
COX_Status (*Duty) (uint16_t pwmout, float duty);
COX_Status (*Start) (uint16_t pwmout);
COX_Status (*Stop) (uint16_t pwmout);
} COX_PWM_PI_Def;
typedef const COX_PWM_PI_Def COX_PWM_PI |
| Member |
COX_Status (*Init) (void);
/* Initialize the PWM peripheral */
COX_Status (*Period) (uint16_t pwmout, float period);
/* Set PWM Output Period in second */
COX_Status (*Width) (uint16_t pwmout, float width);
/* Set the PWM Pulsewidth in second */
COX_Status (*usPeriod) (uint16_t pwmout, uint32_t period);
/* Set PWM Output Period in microsecond */
COX_Status (*usWidth) (uint16_t pwmout, uint32_t width);
/* Set the PWM Pulsewidth in microsecond */
COX_Status (*Duty) (uint16_t pwmout, float duty);
/* Set the ouput duty-cycle, specified as a percentage */
COX_Status (*Start) (uint16_t pwmout);
/* Initiate PWM Output */
COX_Status (*Stop) (uint16_t pwmout);
/* Stop PWM Output */
|
Standard Function
| Name |
Description |
| Init |
Initialize the PWM peripheral |
| Period |
Set PWM Output Period in second |
| Width |
Set the PWM Pulsewidth in second |
| usPeriod |
Set PWM Output Period in microsecond |
| usWidth |
Set the PWM Pulsewidth in microsecond |
| Duty |
Set the ouput duty-cycle, specified as a percentage |
| Start |
Initiate PWM Output |
| Stop |
Stop PWM Output |
| COX_Status Init (void) |
| Description |
Initialize the Serial peripheral |
| Parameter |
None |
| Return Code |
Always COX_SUCCESS |
| COX_Status Period (uint16_t pwmout, float period) |
| Description |
Setup PWM Output Period in second |
| Parameter |
pwmout : PWM output line
period : PWM Output Period in second |
| Return Code |
- COX_SUCCESS : Success
- COX_ERROR : The PWM Output or With value were not supported
|
| COX_Status Width (uint16_t pwmout, float width) |
| Description |
Set the PWM Pulsewidth in second |
| Parameter |
pwmout : PWM Output Line
width : PWM Pulsewidth in second |
| Return Code |
- COX_SUCCESS : Success
- The PWM Output or With value were not supported
|
| COX_Status usPeriod (uint16_t pwmout, float period) |
| Description |
Setup PWM Output Period in microsecond |
| Parameter |
pwmout : PWM output line
period : PWM Output Period in microsecond |
| Return Code |
- COX_SUCCESS : Success
- COX_ERROR : The PWM Output or With value were not supported
|
| COX_Status usWidth (uint16_t pwmout, float width) |
| Description |
Set the PWM Pulsewidth in microsecond |
| Parameter |
pwmout : PWM Output Line
width : PWM Pulsewidth in microsecond |
| Return Code |
- COX_SUCCESS : Success
- The PWM Output or With value were not supported
|
| COX_Status Duty (uint16_t pwmout, float duty) |
| Description |
Set the ouput duty-cycle, specified as a percentage |
| Parameter |
pwmout : PWM output line
duty : Duty-cycle, specified as a percentage |
| Return Code |
- COX_SUCCESS : success
- COX_ERROR : The Duty-cycle was not supported
|
| COX_Status Start (uint16_t pwmout) |
| Description |
Initiate PWM Output |
| Parameter |
pwmout : PWM output line |
| Return Code |
COX_SUCCESS or COX_SUCCESS |
| COX_Status Stop (uint16_t pwmout) |
| Description |
Stop PWM Output |
| Parameter |
pwmout : PWM output line |
| Return Code |
COX_SUCCESS or COX_SUCCESS |
Available Interface
| Vendor |
Chip |
Interface |
Description |
| NXP |
LPC17xx Series |
pi_pwm |
PWM Interface |
|
|