.hi. Everyone.
I want know 0,1,2,3,4, ~ 4998,4999,5000 Hz Freq for PWM function.
PWM Setting -> Channel clock period = 10KHz
input data = 0~1023
16bit PWM
ex) if i want 1hz, 10KHz / 1Hz = 10K = PWMPER01
10KHz / 2Hz = 5K = PWMPER01
.
.
.
10KHz / 700Hz = 3 = PWMPER01
10KHz / 701Hz = 3 = PWMPER01
10KHz / 702Hz = 3 = PWMPER01
10KHz / 703Hz = 3 = PWMPER01
and I want 700,701,702,703Hz etc..... but only PWMPER01 = 3 !!!!
so Output PWM is only 700Hz.
I want solution.
input data is 1,2,3,4,5,6,7,8,etc.....
Output Hz is 1,2,3,4,5,6,7,8 etc Hz
Solved! Go to Solution.
You need at least 25MHz PWM clock to be able to tune PWM frequency up to 5kHz with 1Hz resolution. 10kHz is certainly not enough.
Minimum PWM frequency in 16bits mode at 25MHz clock is 382Hz, so you you need to prescale 25MHz /2 for frequencies 191-381Hz, -"- 25MHz /4 for 95-190Hz, etc.
You need at least 25MHz PWM clock to be able to tune PWM frequency up to 5kHz with 1Hz resolution. 10kHz is certainly not enough.
Minimum PWM frequency in 16bits mode at 25MHz clock is 382Hz, so you you need to prescale 25MHz /2 for frequencies 191-381Hz, -"- 25MHz /4 for 95-190Hz, etc.
Thank you for you'r answer.
Your answer was the setting.
PWMPRCLK = 0x22; // BUS Clk / 4 = 3000000
// BUS Clk = 12MHz
PWMSCLA=0x01; // PWMPRCLK / (2*PWMSCLA) = 3000000 / (2 *1) = 1500000
PWMSCLB=0x01;
And good operation.