PWM
概述
脉冲宽度调制(Pulse width modulation,简称PWM)是一种模拟控制方式,根据相应载荷的变化来调制晶体管基极或MOS管栅极的偏置,来实现晶体管或MOS管导通时间的改变,从而实现开关稳定电源输出的改变。这种方式能使电源的输出电压在工作条件变化时保持恒定,是利用微处理器的数字信号对模拟电路进行控制的一种非常有效的技术,广泛应用在从测量、通信到功率控制与变换的许多领域中。
注解
pwm更多资料请参考 BL602参考手册 。
应用实例
DAC实例: customer_app/peripheral/demo_pwm
。
API参考
Header File
- components/platform/hosal/include/hosal_pwm.h
Functions
-
int
hosal_pwm_init
(hosal_pwm_dev_t *pwm) Initialises a PWM pin.
- Return
- 0 : success
- other: fail
- Parameters
pwm
: the PWM device
-
int
hosal_pwm_start
(hosal_pwm_dev_t *pwm) Starts Pulse-Width Modulation signal output on a PWM pin.
- Return
- 0 : success
- other : fail
- Parameters
pwm
: the PWM device
-
int
hosal_pwm_stop
(hosal_pwm_dev_t *pwm) Stops output on a PWM pin.
- Return
- 0 : success
- other: fail
- Parameters
pwm
: the PWM device
-
int
hosal_pwm_para_chg
(hosal_pwm_dev_t *pwm, hosal_pwm_config_t para) @change the para of pwm
- Return
- 0 : success
- other: fail
- Parameters
pwm
: the PWM devicepara
: the para of pwm
-
int
hosal_pwm_freq_set
(hosal_pwm_dev_t *pwm, uint32_t freq) update PWM frequency
- Return
- 0 : success
- other: fail
- Parameters
pwm
: the PWM devicefreq
: the PWM frequency (0~40M under limited duty)
-
int
hosal_pwm_freq_get
(hosal_pwm_dev_t *pwm, uint32_t *p_freq) get PWM frequency
- Return
- 0 : success
- other: fail
- Parameters
pwm
: the PWM devicep_freq
: the pointer to memory frequency
-
int
hosal_pwm_duty_set
(hosal_pwm_dev_t *pwm, uint32_t duty) set PWM duty
- Return
- 0 : success
- other: fail
- Parameters
pwm
: the PWM deviceduty
: the PWM duty (original duty * 100)
-
int
hosal_pwm_duty_get
(hosal_pwm_dev_t *pwm, uint32_t *p_duty) get PWM duty
- Return
- 0 : success
- other: fail
- Parameters
pwm
: the PWM devicep_duty
: the pointer to memory duty(original duty * 100)
-
int
hosal_pwm_finalize
(hosal_pwm_dev_t *pwm) De-initialises an PWM interface, Turns off an PWM hardware interface.
- Return
- 0 : success
- other: fail
- Parameters
pwm
: the interface which should be de-initialised