Chat freely about anything...

User avatar
By eriksl
#22985 No, that's not it. I am referring to this file. It's in the SDK. At least in 1.1.2 and 1.20. It seems to come from the application example, they didn't remove the references to the examples.

Code: Select all#ifndef __PWM_H__
#define __PWM_H__

/*pwm.h: function and macro definition of PWM API , driver level */
/*user_light.h: user interface for light API, user level*/
/*user_light_adj: API for color changing and lighting effects, user level*/


 /*NOTE!!  : DO NOT CHANGE THIS FILE*/

 /*SUPPORT UP TO 8 PWM CHANNEL*/
#define PWM_CHANNEL_NUM_MAX 8

struct pwm_param {
    uint32 period;
    uint32 freq;
    uint32  duty[PWM_CHANNEL_NUM_MAX];  //PWM_CHANNEL<=8
};


/* pwm_init should be called only once, for now  */
void pwm_init(uint32 period, uint32 *duty,uint32 pwm_channel_num,uint32 (*pin_info_list)[3]);
void pwm_start(void);

void pwm_set_duty(uint32 duty, uint8 channel);
uint32 pwm_get_duty(uint8 channel);
void pwm_set_period(uint32 period);
uint32 pwm_get_period(void);

uint32 get_pwm_version(void);
void set_pwm_debug_en(uint8 print_en);

#endif
Last edited by eriksl on Sat Jul 11, 2015 1:51 am, edited 1 time in total.
User avatar
By eriksl
#22988 @FlyingHacker: PWM is not always used as a "digital dac". I am using it to control led lighting and I purposely do not convert it to analog. A MOSFET can switch much higher currents when driving digitally (fully open and fully closed) then analog and also it's much more efficient. Besides that's it quite difficult to drive a MOSFET in an analogue way because they all have different characteristics in the analogue domain (also within one type).
User avatar
By FlyingHacker
#22989
eriksl wrote:@FlyingHacker: PWM is not always used as a "digital dac". I am using it to control led lighting and I purposely do not convert it to analog. A MOSFET can switch much higher currents when driving digitally (fully open and fully closed) then analog and also it's much more efficient. Besides that's it quite difficult to drive a MOSFET in an analogue way because they all have different characteristics in the analogue domain (also within one type).


Totally true... That is just the most common use of PWM.

And no doubt about the MOSFETs... mainly useful as switches rather than amps.
User avatar
By camilo_avil
#32578 Hi maybe you know it already. The SDK programming guide says"Sets duty cycle of a PWM output. Set the time that high-level single will
last, duty depends on period, the maximum value can be Period * 1000 /45. For example, 1KHz PWM, duty range is 0 ~ 22222".

uint32 duty : the time that high-level single will last, duty cycle will be(duty*45)/ (period*1000)

i didn´t check it yet but a I will