File tree Expand file tree Collapse file tree 1 file changed +20
-3
lines changed
libraries/Basics/examples/PWM Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change 3
3
4
4
void setup () {
5
5
// 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);
8
26
}
9
27
10
28
uint16_t a=0 ;
11
29
uint16_t b=0 ;
12
30
13
31
void loop () {
14
- // PWM frequency is 65535
15
32
analogWrite (PWM1,a);
16
33
analogWrite (PWM2,b);
17
34
delay (10 );
You can’t perform that action at this time.
0 commit comments