File tree 2 files changed +6
-2
lines changed
2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ SAMD CORE
4
4
* Added snprintf_P to avr/pgmspace.h stub. Thanks @jantje
5
5
* Another small fix to String iterators. Thanks @Ivan-Perez @Chris--A
6
6
* Fixed glitch in PWM generation that may happen when calling analogWrite()
7
+ * PWM frequency is now 732.4Hz (before it was 187500.0Hz)
7
8
8
9
SAMD CORE 1.6.6 2016.05.19
9
10
Original file line number Diff line number Diff line change @@ -256,8 +256,8 @@ void analogWrite(uint32_t pin, uint32_t value)
256
256
// Disable TCx
257
257
TCx -> COUNT8 .CTRLA .bit .ENABLE = 0 ;
258
258
syncTC_8 (TCx );
259
- // Set Timer counter Mode to 8 bits, normal PWM
260
- TCx -> COUNT8 .CTRLA .reg |= TC_CTRLA_MODE_COUNT8 | TC_CTRLA_WAVEGEN_NPWM ;
259
+ // Set Timer counter Mode to 8 bits, normal PWM, prescaler 1/256
260
+ TCx -> COUNT8 .CTRLA .reg |= TC_CTRLA_MODE_COUNT8 | TC_CTRLA_WAVEGEN_NPWM | TC_CTRLA_PRESCALER_DIV256 ;
261
261
syncTC_8 (TCx );
262
262
// Set the initial value
263
263
TCx -> COUNT8 .CC [tcChannel ].reg = (uint8_t ) value ;
@@ -274,6 +274,9 @@ void analogWrite(uint32_t pin, uint32_t value)
274
274
// Disable TCCx
275
275
TCCx -> CTRLA .bit .ENABLE = 0 ;
276
276
syncTCC (TCCx );
277
+ // Set prescaler to 1/256
278
+ TCCx -> CTRLA .reg |= TCC_CTRLA_PRESCALER_DIV256 ;
279
+ syncTCC (TCCx );
277
280
// Set TCx as normal PWM
278
281
TCCx -> WAVE .reg |= TCC_WAVE_WAVEGEN_NPWM ;
279
282
syncTCC (TCCx );
You can’t perform that action at this time.
0 commit comments