rfLPC
A low level library for using NXP's LPC17xx SoC. Config is given for MBED prototyping board
Pulse Width Modulation

Functions

int rflpc_pwm_init (rflpc_pin_t pin)
 Inits the PWM peripheral for use with selected pin. More...
 
void rflpc_pwm_start (void)
 Starts pwm duty cycle. More...
 
void rflpc_pwm_stop (void)
 Stops pwm duty cycle. More...
 
void rflpc_pwm_reset (void)
 Resets pwm duty cycle (restart at the start of a period. More...
 
void rflpc_pwm_set_period (uint32_t period)
 Sets the period in micro seconds. More...
 
void rflpc_pwm_single_edge (rflpc_pin_t pin, uint32_t pulsewidth)
 Sets the pwm parameters in single edge mode. More...
 
void rflpc_pwm_double_edge (rflpc_pin_t pin, uint32_t high_edge, uint32_t low_edge)
 Sets the pwm parameters to operate on double edge mode. More...
 
void rflpc_pwm_enable (rflpc_pin_t pin)
 Enable the PWM on the given pin (do not reset the timer, only enable PWM output) More...
 
void rflpc_pwm_disable (rflpc_pin_t pin)
 Disable the PWM output on the given pin. More...
 

Detailed Description

Function Documentation

void rflpc_pwm_disable ( rflpc_pin_t  pin)

Disable the PWM output on the given pin.

Warning
This will let the pin at the state it has.
Parameters
pin
void rflpc_pwm_double_edge ( rflpc_pin_t  pin,
uint32_t  high_edge,
uint32_t  low_edge 
)

Sets the pwm parameters to operate on double edge mode.

Parameters
pinthe PWM pin (same restrictions as in rflpc_pwm_init)
high_edgetime at which the PWM ouput goes in high state (in microseconds)
low_edgetime at which the PWM ouput goes in low state (in microseconds)
Warning
In double edge mode, the match register used to select low and high state can are shared with previous and next PWM channel. See user manual page 512 to see how match registers are shared between PWM channels.
PWM1 can not be used as double edged
void rflpc_pwm_enable ( rflpc_pin_t  pin)

Enable the PWM on the given pin (do not reset the timer, only enable PWM output)

Parameters
pin
int rflpc_pwm_init ( rflpc_pin_t  pin)

Inits the PWM peripheral for use with selected pin.

Note
not all pins are available! And one PWM channel can only be used on one pin at a time. Available pins are:
  • P1_18 and P2_0 for PWM1
  • P1_20, P2_1 and P3_25 for PWM2
  • P1_21, P2_2 and P3_26 for PWM3
  • P1_23 and P2_3 for PWM4
  • P1_24 and P2_4 for PWM5
  • P1_26 and P2_5 for PWM6
Returns
returns -1 on error and 0 if no problem occurs
void rflpc_pwm_reset ( void  )

Resets pwm duty cycle (restart at the start of a period.

void rflpc_pwm_set_period ( uint32_t  period)

Sets the period in micro seconds.

If the PWM timer was running, it is stop, reset and restarted to start on the new period.

Parameters
period
void rflpc_pwm_single_edge ( rflpc_pin_t  pin,
uint32_t  pulsewidth 
)

Sets the pwm parameters in single edge mode.

This call makes the PWM outputs a pulse of a given width at the start of each period

Parameters
pinthe PWM pin (same restriction as rflpc_pwm_init apply)
pulsewidthThe width of the pulse in micro seconds
void rflpc_pwm_start ( void  )

Starts pwm duty cycle.

void rflpc_pwm_stop ( void  )

Stops pwm duty cycle.