Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working on 1284P - have fix #4

Open
bHogan2 opened this issue May 9, 2015 · 4 comments
Open

Not working on 1284P - have fix #4

bHogan2 opened this issue May 9, 2015 · 4 comments

Comments

@bHogan2
Copy link

bHogan2 commented May 9, 2015

TimerOne is working on 328P AND the 644P but not on 1284P.
I am using the latest TimerOne and Mighty 1284 core.
Tried on IDE 1.0.6 and 1.6.4. with more than one chip.

I noticed a diff in pins between the 644 and 1284.

elif defined(AVR_ATmega644P) || defined(AVR_ATmega644)

#define TIMER1_A_PIN 13
#define TIMER1_B_PIN 12
. . . versis . . .

elif defined(AVR_ATmega1284P)

#define TIMER1_A_PIN 12 // PD5 <<<<<< SB 13?
#define TIMER1_B_PIN 13 // PD4 <<<<<<< SB 12?

I switched 12 and 13 for the 1284 and it's working now.
Hopefully it's a typo and I don't have some kind of bizarro problem :)

Thanks for a great lib and all the work to support so many devices.
John

@PaulStoffregen
Copy link
Owner

Looks like this was fixed long ago.

// Mighty-1284 - Maniacbug
//
#elif defined(__AVR_ATmega1284P__)
  #define TIMER1_A_PIN   12  // PD5
  #define TIMER1_B_PIN   13  // PD4
  #define TIMER1_ICP_PIN 14  // PD6
  #define TIMER1_CLK_PIN 1   // PB1
  #define TIMER3_A_PIN   6   // PB6
  #define TIMER3_B_PIN   7   // PB7
  #define TIMER3_ICP_PIN 5   // PB5
  #define TIMER3_CLK_PIN 8   // PD0

I'm closing this old issue. If there's still a problem, please reopen and explain...

@MadGarra
Copy link

MadGarra commented Jul 15, 2016

Sorry, but it is not fixed. According to ATmega164A/164PA/324A/324PA/644A/644PA/1284/1284P datashhet (Section 1.1 - Pinout - PDIP...),
OC1A - PD5 port is assigned to PIN19 = Maniacbug D 13
OC1B - PD4 port is assigned to PIN18 = Maniacbug D 12

ManiacBug PIN mapping

                      +---\/---+
           (D 0) PB0 1|        |40 PA0 (AI 0 / D24)
           (D 1) PB1 2|        |39 PA1 (AI 1 / D25)
      INT2 (D 2) PB2 3|        |38 PA2 (AI 2 / D26)
       PWM (D 3) PB3 4|        |37 PA3 (AI 3 / D27)
    PWM/SS (D 4) PB4 5|        |36 PA4 (AI 4 / D28)
      MOSI (D 5) PB5 6|        |35 PA5 (AI 5 / D29)
  PWM/MISO (D 6) PB6 7|        |34 PA6 (AI 6 / D30)
   PWM/SCK (D 7) PB7 8|        |33 PA7 (AI 7 / D31)
                 RST 9|        |32 AREF
                VCC 10|        |31 GND
                GND 11|        |30 AVCC
              XTAL2 12|        |29 PC7 (D 23)
              XTAL1 13|        |28 PC6 (D 22)
      RX0 (D 8) PD0 14|        |27 PC5 (D 21) TDI
      TX0 (D 9) PD1 15|        |26 PC4 (D 20) TDO
RX1/INT0 (D 10) PD2 16|        |25 PC3 (D 19) TMS
TX1/INT1 (D 11) PD3 17|        |24 PC2 (D 18) TCK
     PWM (D 12) PD4 18|        |23 PC1 (D 17) SDA
     PWM (D 13) PD5 19|        |22 PC0 (D 16) SCL
     PWM (D 14) PD6 20|        |21 PD7 (D 15) PWM
                      +--------+

Therefore, the code should be changed from

#elif defined(__AVR_ATmega1284P__)
  #define TIMER1_A_PIN   12  // PD5
  #define TIMER1_B_PIN   13  // PD4
  #define TIMER1_ICP_PIN 14  // PD6

to

#elif defined(__AVR_ATmega1284P__)
  #define TIMER1_A_PIN   13  // PD5
  #define TIMER1_B_PIN   12  // PD4
  #define TIMER1_ICP_PIN 14  // PD6

@vdesmedt
Copy link

vdesmedt commented Sep 16, 2020

I confirm the problem is not solved.

This code :
void setup() { //Timer1.initialize(1000); //Timer1.attachInterrupt(timerIsr); analogWrite(P_FAN_PWM, 128); }

Produces correct result

while this code
void setup() { Timer1.initialize(1000); Timer1.attachInterrupt(timerIsr); analogWrite(P_FAN_PWM, 128); }

Creates a very thin spike instead of the square wave the above code produces

@eeproto
Copy link

eeproto commented Mar 25, 2021

I just ran into the same issue. Things work fine on the ATmega1284 when you modify known_16bit_timers.h to read:

// Mighty-1284 - Maniacbug
//
#elif defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega1284__)
  #define TIMER1_A_PIN   13  // PD5
  #define TIMER1_B_PIN   12  // PD4
  #define TIMER1_ICP_PIN 14  // PD6
  #define TIMER1_CLK_PIN 1   // PB1
  #define TIMER3_A_PIN   6   // PB6
  #define TIMER3_B_PIN   7   // PB7
  #define TIMER3_ICP_PIN 5   // PB5
  #define TIMER3_CLK_PIN 8   // PD0

#endif

This also enables TimerOne to run on a non-P ATmega1284. Tested with an ATmega1284-MU.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants