PWM on pin 4 (TIMER1B).

This fixes issue #36 (for Arduino 1.5.x at least). It uses
initVariant() to put Timer1 into PWM mode and a hacky #define alias
(TCCR1A for GTCCR) so that analogWrite() will set the right bit in the
right register to connect the timer PWM output to the pin. Also, the
pre-scale factor and PWM frequency are probably wrong (or, at least,
not the same as on other AVRs).
This commit is contained in:
David A. Mellis 2014-08-06 17:39:52 -04:00
parent 5123918765
commit f265d1725f

View File

@ -51,8 +51,15 @@ static const uint8_t A3 = 9;
#define analogPinToChannel(p) ( (p) < 6 ? (p) : (p) - 6 )
#define TCCR1A GTCCR
#ifdef ARDUINO_MAIN
void initVariant()
{
GTCCR |= (1 << PWM1B);
}
// these arrays map port names (e.g. port B) to the
// appropriate addresses for various functions (e.g. reading
// and writing) tiny45 only port B
@ -106,7 +113,7 @@ const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
TIMER0B,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,
TIMER1B,
NOT_ON_TIMER,
NOT_ON_TIMER,
NOT_ON_TIMER,