PWM Structures - PalouseRobosub/SUBLIBinal GitHub Wiki
PWM Structures
This page documents the structures used within the PWM peripheral library of SUBLIBinal. Please select the appropriate structure from the list below to read more about it.
Structures
PWM_Config
Definition
typedef struct {
float dutyCycle;
Timer_Type timer;
Pin pin; //our output pin
uint8 enable;
PWM_Channel channel;
}PWM_Config;
Description
The PWM_Config
structure is used for configuring a PWM channel for use.
Parameters
- float dutyCycle: this should be a value between 0 and 1 and specifies the duty cycle of the PWM waveform.
- Timer_Type timer: This should be a timer enumeration to specify the source timer for the PWM timer. This parameter may only be Timer_2 or Timer_3, or the PWM will not function.
- Pin pin: Ththis should be a complete filled out and initialized timer structure that will be used for the PWM generation. Only the PWM frequency depends on this structure. The timer structure can only utilize timers 2 and 3 for PWM generation. No other timers may be used.is should be the desired output pin. Please refer to the documentation on page 11 and 12 to determine which pins are available for use by your selected PWM channel specified in
channel
. - bool enable: this parameter specifies whether the PWM should be enabled after configuration
- PWM_Channel channel: this specifies which PWM channel will be used. Each channel can only be used to generate a single PWM waveform.