Use pwm_init experiencing some problems

huafan
Posts: 32
Joined: Sun Mar 15, 2015 2:30 pm

Use pwm_init experiencing some problems

Postby huafan » Thu Mar 26, 2015 4:35 pm

I use SDK V1.0.0
GPIO0
pwm_init freq range 1 - 500
freq eq 500 it is OK,
freq eq 100 it is OK,
but freq eq 50 and 10 ,It is a problem.

attachment
code: freq = 10HZ
Oscilloscope picture: freq = 10HZ
code: freq = 50HZ
Oscilloscope picture: freq = 50HZ
code: freq = 100HZ
Oscilloscope picture: freq = 100HZ
Attachments
调试截图.zip
调试截图
(389.35 KiB) Downloaded 640 times

costaud
Posts: 138
Joined: Fri Oct 24, 2014 7:40 pm

Re: Use pwm_init experiencing some problems

Postby costaud » Tue Mar 31, 2015 6:10 pm

将pwm.h中pwm_single_param 和pwm_param 结构体参数类型做以下修改即可解决问题:

uint16 h_time; 改为 uint32 h_time;

uint16 period; 改为 uint32 period;

修改后为:

struct pwm_single_param {
uint16 gpio_set;
uint16 gpio_clear;
uint32 h_time;
};

struct pwm_param {
uint32 period;
uint16 freq;
uint8 duty[PWM_CHANNEL];
};

Who is online

Users browsing this forum: No registered users and 163 guests