Skip to content

Commit 9401e47

Browse files
updated pwm example
1 parent 543efe8 commit 9401e47

File tree

1 file changed

+20
-3
lines changed
  • libraries/Basics/examples/PWM

1 file changed

+20
-3
lines changed

libraries/Basics/examples/PWM/PWM.ino

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,32 @@
33

44
void setup() {
55
// put your setup code here, to run once:
6-
pinMode(PWM1,OUTPUT);
7-
pinMode(PWM2,OUTPUT);
6+
7+
/*PWM CLK frequency default is 12M;
8+
*PWM CLK frequency value:
9+
*PWM_CLK_FREQ_48M
10+
*PWM_CLK_FREQ_24M
11+
*PWM_CLK_FREQ_16M
12+
*PWM_CLK_FREQ_12M
13+
*PWM_CLK_FREQ_8M
14+
*PWM_CLK_FREQ_6M
15+
*PWM_CLK_FREQ_4M
16+
*PWM_CLK_FREQ_3M
17+
*PWM_CLK_FREQ_2M
18+
*PWM_CLK_FREQ_1M
19+
*/
20+
setPWM_Frequency(PWM_CLK_FREQ_12M);
21+
22+
//pwm period can be 0xFF~0xFFFF, default is 0xFFFF
23+
setPWM_ComparePeriod(0xFFFF);
24+
pinMode(PWM1,OUTPUT);
25+
pinMode(PWM2,OUTPUT);
826
}
927

1028
uint16_t a=0;
1129
uint16_t b=0;
1230

1331
void loop() {
14-
// PWM frequency is 65535
1532
analogWrite(PWM1,a);
1633
analogWrite(PWM2,b);
1734
delay(10);

0 commit comments

Comments
 (0)