SDK3.5
This document shows Ameba SDK 3.5 APIs

pwm functions More...

Ameba Common

typedef struct pwmout_s pwmout_t
 
void pwmout_init (pwmout_t *obj, PinName pin)
 Initializes the PWM function/registers of the specified pin with default parameters. More...
 
void pwmout_free (pwmout_t *obj)
 Deinitializes the PWM device of the specified channel. More...
 
void pwmout_write (pwmout_t *obj, float percent)
 Set the duty cycle of the specified channel. More...
 
float pwmout_read (pwmout_t *obj)
 Get the duty cycle value of the specified channel. More...
 
void pwmout_period (pwmout_t *obj, float seconds)
 Set the period of the specified channel in seconds. More...
 
void pwmout_period_ms (pwmout_t *obj, int ms)
 Set the period of the specified channel in millseconds. More...
 
void pwmout_period_us (pwmout_t *obj, int us)
 Set the period of the specified channel in microseconds. More...
 
void pwmout_pulsewidth (pwmout_t *obj, float seconds)
 Set the pulse width of the specified channel in seconds. More...
 
void pwmout_pulsewidth_ms (pwmout_t *obj, int ms)
 Set the pulse width of the specified channel in milliseconds. More...
 
void pwmout_pulsewidth_us (pwmout_t *obj, int us)
 Set the pulse width of the specified channel in microseconds. More...
 

Detailed Description

pwm functions

Function Documentation

void pwmout_free ( pwmout_t *  obj)

Deinitializes the PWM device of the specified channel.

Parameters
objPWM object define in application software.
Return values
none
Note
If all channels are released, TIM5 will also be disabled.
void pwmout_init ( pwmout_t *  obj,
PinName  pin 
)

Initializes the PWM function/registers of the specified pin with default parameters.

Parameters
objPWM object define in application software.
pinthe pinname of specified channel to be set.
Return values
none
Note
  • default period: 1638us
  • default pulse width: 102us
  • default duty cycle: 6.227%
void pwmout_period ( pwmout_t *  obj,
float  seconds 
)

Set the period of the specified channel in seconds.

Parameters
objPWM object define in application software.
secondsThe period value to be set in seconds.
Return values
none
void pwmout_period_ms ( pwmout_t *  obj,
int  ms 
)

Set the period of the specified channel in millseconds.

Parameters
objPWM object define in application software.
msThe period value to be set in millseconds.
Return values
none
void pwmout_period_us ( pwmout_t *  obj,
int  us 
)

Set the period of the specified channel in microseconds.

Parameters
objPWM object define in application software.
usThe period value to be set in microseconds.
Return values
none
void pwmout_pulsewidth ( pwmout_t *  obj,
float  seconds 
)

Set the pulse width of the specified channel in seconds.

Parameters
objPWM object define in application software.
secondsThe pulse width value to be set in seconds.
Return values
none
void pwmout_pulsewidth_ms ( pwmout_t *  obj,
int  ms 
)

Set the pulse width of the specified channel in milliseconds.

Parameters
objPWM object define in application software.
msThe pulse width value to be set in milliseconds.
Return values
none
void pwmout_pulsewidth_us ( pwmout_t *  obj,
int  us 
)

Set the pulse width of the specified channel in microseconds.

Parameters
objPWM object define in application software.
usThe pulse width value to be set in microseconds.
Return values
none
float pwmout_read ( pwmout_t *  obj)

Get the duty cycle value of the specified channel.

Parameters
objPWM object define in application software.
Return values
the duty cycle value of the specified channel.
void pwmout_write ( pwmout_t *  obj,
float  percent 
)

Set the duty cycle of the specified channel.

Parameters
objPWM object define in application software.
percentThe duty cycle value to be set.
Return values
none