NEORV32 Software Framework Documentation
The NEORV32 RISC-V Processor
Loading...
Searching...
No Matches
neorv32_pwm.c File Reference

Pulse-Width Modulation Controller (PWM) HW driver source file. More...

#include <neorv32.h>

Functions

int neorv32_pwm_available (void)
 
int neorv32_pmw_get_num_channels (void)
 
void neorv32_pwm_ch_enable (int channel)
 
void neorv32_pwm_ch_disable (int channel)
 
void neorv32_pwm_ch_set_clock (int channel, int prsc, int cdiv)
 
void neorv32_pwm_ch_set_duty (int channel, int duty)
 

Detailed Description

Pulse-Width Modulation Controller (PWM) HW driver source file.

Note
These functions should only be used if the PWM unit was synthesized (IO_PWM_EN = true).
See also
https://stnolting.github.io/neorv32/sw/files.html

Function Documentation

◆ neorv32_pmw_get_num_channels()

int neorv32_pmw_get_num_channels ( void )

Get number of implemented PWM channels.

Warning
This function will override all channel configuration registers.
Returns
Number of implemented PWM channels.

◆ neorv32_pwm_available()

int neorv32_pwm_available ( void )

Check if PWM unit was synthesized.

Returns
0 if PWM was not synthesized, 1 if PWM is available.

◆ neorv32_pwm_ch_disable()

void neorv32_pwm_ch_disable ( int channel)

Disable PWM channel.

Parameters
[in]channelChannel select (0..15).

◆ neorv32_pwm_ch_enable()

void neorv32_pwm_ch_enable ( int channel)

Enable PWM channel.

Parameters
[in]channelChannel select (0..15).

◆ neorv32_pwm_ch_set_clock()

void neorv32_pwm_ch_set_clock ( int channel,
int prsc,
int cdiv )

Set PWM channel's clock configuration.

Parameters
[in]channelChannel select (0..15).
[in]prscCoarse clock prescaler select (3-bit, LSB-aligned). See NEORV32_CLOCK_PRSC_enum.
[in]cdivFine clock divider value (10-bit, LSB-aligned).

◆ neorv32_pwm_ch_set_duty()

void neorv32_pwm_ch_set_duty ( int channel,
int duty )

Set PWM channel's duty cycle.

Parameters
[in]channelChannel select (0..15).
[in]dutyDuty cycle (8-bit, LSB-aligned).