Question on pwm using due
hi all,
i newbie in arduino due , when trying due generate pwm, found behavior cannot explain.
i called on pin 7, , default frequency 1 khz , uses signal pwm clock a, no problem.
then, went change register pwm clock register value , try higher. according due cpu datasheet, when set prea , diva value clock has same frequency mck, expecting close 84 mhz instead, got square wave of 329 khz (still 50% duty cycle), 84 mhz / 255.
i don't see anywhere else on pwm section of datasheet 1 can divide mck frequency. confused on 255 coming from. if can make use of divider, helpful.
here code:
i have looked channel mode register, if uses clk or clk b, there 1 option without divider. please find link datasheet here: http://www.atmel.com/images/doc11057.pdf
thanks time. appreciated.
f33d
i newbie in arduino due , when trying due generate pwm, found behavior cannot explain.
i called on pin 7, , default frequency 1 khz , uses signal pwm clock a, no problem.
then, went change register pwm clock register value , try higher. according due cpu datasheet, when set prea , diva value clock has same frequency mck, expecting close 84 mhz instead, got square wave of 329 khz (still 50% duty cycle), 84 mhz / 255.
i don't see anywhere else on pwm section of datasheet 1 can divide mck frequency. confused on 255 coming from. if can make use of divider, helpful.
here code:
code: [select]
#include <spi.h>
#define pwm_wpcr (*(volatile unsigned long int *) 0x400940e4) //datasheet 1053
#define pwm_clk (*(volatile unsigned long int *) 0x40094000) // datasheet 1020
void setup() {
analogwrite(7, 127);
pwm_wpcr = 0x50574d3c; // disable write protection pwm
pwm_clk = 0x00000001; // clk mck, disable clk b
}
i have looked channel mode register, if uses clk or clk b, there 1 option without divider. please find link datasheet here: http://www.atmel.com/images/doc11057.pdf
thanks time. appreciated.
f33d
for pwm, actual clock rate pwm frequency times pwm count. 8 bit resolution, count 255.
therefore max pwm frequency 8 bit resolution mck/255, have found.
therefore max pwm frequency 8 bit resolution mck/255, have found.
Arduino Forum > Products > Arduino Due (Moderator: fabioc84) > Question on pwm using due
arduino
Comments
Post a Comment