LPCOpen Platform for LPC18XX/43XX microcontrollers  18XX43XX
LPCOpen Platform for the NXP LPC18XX/43XX family of Microcontrollers
Functions
CHIP: LPC18XX_43XX State Configurable Timer PWM driver

Detailed Description

For more information on how to use the driver please visit the FAQ page at www.lpcware.com

Functions

STATIC INLINE uint32_t Chip_SCTPWM_GetTicksPerCycle (LPC_SCT_T *pSCT)
 Get number of ticks per PWM cycle. More...
 
STATIC INLINE uint32_t Chip_SCTPWM_PercentageToTicks (LPC_SCT_T *pSCT, uint8_t percent)
 Converts a percentage to ticks. More...
 
STATIC INLINE uint32_t Chip_SCTPWM_GetDutyCycle (LPC_SCT_T *pSCT, uint8_t index)
 Get number of ticks on per PWM cycle. More...
 
STATIC INLINE void Chip_SCTPWM_SetDutyCycle (LPC_SCT_T *pSCT, uint8_t index, uint32_t ticks)
 Get number of ticks on per PWM cycle. More...
 
STATIC INLINE void Chip_SCTPWM_Init (LPC_SCT_T *pSCT)
 Initialize the SCT/PWM clock and reset. More...
 
STATIC INLINE void Chip_SCTPWM_Start (LPC_SCT_T *pSCT)
 Start the SCT PWM. More...
 
STATIC INLINE void Chip_SCTPWM_Stop (LPC_SCT_T *pSCT)
 Stop the SCT PWM. More...
 
void Chip_SCTPWM_SetRate (LPC_SCT_T *pSCT, uint32_t freq)
 Sets the frequency of the generated PWM wave. More...
 
void Chip_SCTPWM_SetOutPin (LPC_SCT_T *pSCT, uint8_t index, uint8_t pin)
 Setup the OUTPUT pin and associate it with an index. More...
 

Function Documentation

STATIC INLINE uint32_t Chip_SCTPWM_GetDutyCycle ( LPC_SCT_T pSCT,
uint8_t  index 
)

Get number of ticks on per PWM cycle.

Parameters
pSCT: The base of SCT peripheral on the chip
index: Index of the PWM 1 to N (see notes)
Returns
Number ot ticks for which the output will be ON per cycle
Note
index will be 1 to N where N is the "Number of match registers available in the SCT - 1" or "Number of OUTPUT pins available in the SCT" whichever is minimum.

Definition at line 86 of file sct_pwm_18xx_43xx.h.

STATIC INLINE uint32_t Chip_SCTPWM_GetTicksPerCycle ( LPC_SCT_T pSCT)

Get number of ticks per PWM cycle.

Parameters
pSCT: The base of SCT peripheral on the chip
Returns
Number ot ticks that will be counted per cycle
Note
Return value of this function will be vaild only after calling Chip_SCTPWM_SetRate()

Definition at line 56 of file sct_pwm_18xx_43xx.h.

STATIC INLINE void Chip_SCTPWM_Init ( LPC_SCT_T pSCT)

Initialize the SCT/PWM clock and reset.

Parameters
pSCT: The base of SCT peripheral on the chip
Returns
None

Definition at line 113 of file sct_pwm_18xx_43xx.h.

STATIC INLINE uint32_t Chip_SCTPWM_PercentageToTicks ( LPC_SCT_T pSCT,
uint8_t  percent 
)

Converts a percentage to ticks.

Parameters
pSCT: The base of SCT peripheral on the chip
percent: Percentage to convert (0 - 100)
Returns
Number ot ticks corresponding to given percentage
Note
Do not use this function when using very low pwm rate (like 100Hz or less), on a chip that has very high frequency as the calculation might cause integer overflow

Definition at line 71 of file sct_pwm_18xx_43xx.h.

STATIC INLINE void Chip_SCTPWM_SetDutyCycle ( LPC_SCT_T pSCT,
uint8_t  index,
uint32_t  ticks 
)

Get number of ticks on per PWM cycle.

Parameters
pSCT: The base of SCT peripheral on the chip
index: Index of the PWM 1 to N (see notes)
ticks: Number of ticks the output should say ON
Returns
None
Note
index will be 1 to N where N is the "Number of match registers available in the SCT - 1" or "Number of OUTPUT pins available in the SCT" whichever is minimum. The new duty cycle will be effective only after completion of current PWM cycle.

Definition at line 103 of file sct_pwm_18xx_43xx.h.

void Chip_SCTPWM_SetOutPin ( LPC_SCT_T pSCT,
uint8_t  index,
uint8_t  pin 
)

Setup the OUTPUT pin and associate it with an index.

Parameters
pSCT: The base of the SCT peripheral on the chip
index: Index of PWM 1 to N (see notes)
pin: COUT pin to be associated with the index
Returns
None
Note
index will be 1 to N where N is the "Number of match registers available in the SCT - 1" or "Number of OUTPUT pins available in the SCT" whichever is minimum.

Definition at line 51 of file sct_pwm_18xx_43xx.c.

void Chip_SCTPWM_SetRate ( LPC_SCT_T pSCT,
uint32_t  freq 
)

Sets the frequency of the generated PWM wave.

Parameters
pSCT: The base of SCT peripheral on the chip
freq: Frequency in Hz
Returns
None

Definition at line 67 of file sct_pwm_18xx_43xx.c.

STATIC INLINE void Chip_SCTPWM_Start ( LPC_SCT_T pSCT)

Start the SCT PWM.

Parameters
pSCT: The base of SCT peripheral on the chip
Returns
None
Note
This function must be called after all the configuration is completed. Do not call Chip_SCTPWM_SetRate() or Chip_SCTPWM_SetOutPin() after the SCT/PWM is started. Use Chip_SCTPWM_Stop() to stop the SCT/PWM before reconfiguring, Chip_SCTPWM_SetDutyCycle() can be called when the SCT/PWM is running to change the DutyCycle.

Definition at line 129 of file sct_pwm_18xx_43xx.h.

STATIC INLINE void Chip_SCTPWM_Stop ( LPC_SCT_T pSCT)

Stop the SCT PWM.

Parameters
pSCT: The base of SCT peripheral on the chip
Returns
None

Definition at line 139 of file sct_pwm_18xx_43xx.h.