SDK4.0 This document shows Ameba SDK 4.0 APIs

- Main Page
- Modules
- Data Structures
- Files

PWM
Ameba SDK » HAL

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

  obj | PWM 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

  obj | PWM object define in application software.
  pin | the 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

  obj | PWM object define in application software.
  seconds | The 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

  obj | PWM object define in application software.
  ms | The 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

  obj | PWM object define in application software.
  us | The 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

  obj | PWM object define in application software.
  seconds | The 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

  obj | PWM object define in application software.
  ms | The 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

  obj | PWM object define in application software.
  us | The 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

  obj | PWM 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

  obj | PWM object define in application software.
  percent | The duty cycle value to be set.

Return values

  none |