Skip to content

Commit 20bc39a

Browse files
author
alastair.mccormack
committed
Corrected TIMER4_HS output on Sparkfun Pro Micro
Use O̅C̅4̅A̅ (complimentary output pin) to output to pin 5 (shared with OC3A) on Sparkfun Pro Micro
1 parent c2d25b4 commit 20bc39a

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ We are open to suggestions for adding support to new boards, however we highly r
5757
| [Teensy++ 1.0 / 2.0](https://www.pjrc.com/teensy/) | **1**, 16, 25 | 1, **2**, 3 |
5858
| [Teensy 3.0 / 3.1](https://www.pjrc.com/teensy/) | **5** | **CMT** |
5959
| [Teensy-LC](https://www.pjrc.com/teensy/) | **16** | **TPM1** |
60-
| [Sparkfun Pro Micro](https://www.sparkfun.com/products/12640) | 9, **5**, 5 | 1, **3**, 4 |
60+
| [Sparkfun Pro Micro](https://www.sparkfun.com/products/12640) | 9, **5**, 5 | 1, **3**, 4_HS |
6161

6262

6363
### Experimental patches

boarddefs.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@
252252
# define TIMER_PWM_PIN CORE_OC1A_PIN // Teensy
253253
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
254254
# define TIMER_PWM_PIN 11 // Arduino Mega
255-
#elif
256255
#elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
257256
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
258257
|| defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324A__) \
@@ -261,7 +260,7 @@
261260
|| defined(__AVR_ATmega16__) || defined(__AVR_ATmega8535__) \
262261
|| defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__)
263262
# define TIMER_PWM_PIN 13 // MightyCore, // MegaCore
264-
#elif defined(__AVR_ATtiny84__) ||
263+
#elif defined(__AVR_ATtiny84__)
265264
# define TIMER_PWM_PIN 6
266265
#else
267266
# define TIMER_PWM_PIN 9 // Arduino Duemilanove, Diecimila, LilyPad, Sparkfun Pro Micro etc
@@ -311,12 +310,21 @@
311310
#elif defined(IR_USE_TIMER4_HS)
312311

313312
#define TIMER_RESET
314-
#define TIMER_ENABLE_PWM (TCCR4A |= _BV(COM4A1))
315-
#define TIMER_DISABLE_PWM (TCCR4A &= ~(_BV(COM4A1)))
313+
314+
#if defined(ARDUINO_AVR_PROMICRO) // Sparkfun Pro Micro
315+
#define TIMER_ENABLE_PWM (TCCR4A |= _BV(COM4A0)) // Use complimentary O̅C̅4̅A̅ output on pin 5
316+
#define TIMER_DISABLE_PWM (TCCR4A &= ~(_BV(COM4A0))) // (Pro Micro does not map PC7 (32/ICP3/CLK0/OC4A)
317+
// of ATmega32U4 )
318+
#else
319+
#define TIMER_ENABLE_PWM (TCCR4A |= _BV(COM4A1))
320+
#define TIMER_DISABLE_PWM (TCCR4A &= ~(_BV(COM4A1)))
321+
#endif
322+
316323
#define TIMER_ENABLE_INTR (TIMSK4 = _BV(TOIE4))
317324
#define TIMER_DISABLE_INTR (TIMSK4 = 0)
318325
#define TIMER_INTR_NAME TIMER4_OVF_vect
319326

327+
320328
#define TIMER_CONFIG_KHZ(val) ({ \
321329
const uint16_t pwmval = SYSCLOCK / 2000 / (val); \
322330
TCCR4A = (1<<PWM4A); \

0 commit comments

Comments
 (0)