Go Down

Topic: Atmega2561 (Read 7386 times) previous topic - next topic

CrossRoads

I was asked about Atmega2561, a 2560 variant in 64 TQFP package.
So I decided to see what I could do to make a 2561 system on a chip type design.
Here's what I came up with.
Anyone have suggestions for Digital IO pin assignments? Is there a 2561 board type already that is Mega-like?
Anyone have any suggestions for the design? I merely broke out all the pins to 0.1" pitch headers, added bare-minimum components (6 x 35mm SMD crystal & caps, pullup Resistor, decoupling & DTR caps) to the bottom, and broke out a Serial interface and ICSP header.
Anything else, add it to your external design.  All fits on a 1.6" x 1.4" board.

Or leave the components off the bottom and just use it as a breakout board.

I have designed similar 2560 board which I am having a couple assembled shortly, just waiting on solder paste stencils.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

somedude

#1
Oct 21, 2015, 01:36 pm Last Edit: Oct 21, 2015, 01:38 pm by somedude
This is probably useless information, but here it is, just in case.
There is a board out there based on the 1281: the Libelium Waspmote.
I think that is the 128K version of the 2561, I will check.
It uses a modified IDE for programming, but it may already feature a pins layout file.
I will check when I get to a machine that has it installed and post here, in case it is useful to you.

Short of that, why not go with Bobuino++... ;)

CrossRoads

2561 is already in avrdude.conf, so maybe I can get away with just this in boards.txt and a new pins_Arduino.h variant:
Code: [Select]


mega2561.name=Arduino Mega 2561

mega2561.upload.protocol=wiring

mega2561.upload.maximum_size=258048

mega2561.upload.speed=115200

mega2561.bootloader.low_fuses=0xFF

mega2561.bootloader.high_fuses=0xD8

mega2561.bootloader.extended_fuses=0xFD

mega2561.bootloader.path=stk500v2

mega2561.bootloader.file=stk500boot_v2_mega2560.hex

mega2561.bootloader.unlock_bits=0x3F

mega2561.bootloader.lock_bits=0x0F

mega2561.build.mcu=atmega2561

mega2561.build.f_cpu=16000000L

mega2561.build.core=arduino

mega2561.build.variant=mega

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

CrossRoads

And this for pins_arduino.h entry for the 2561. Needs a little work in PCINT area still, I don't follow what it's doing yet.
I trimmed a bunch of similar stuff that  I do understand so it fits here, mostly so the port assignments I am contemplating can be seen.

Code: [Select]

/*
  pins_arduino.h - Pin definition functions for Arduino
  Part of Arduino - [iurl=http://www.arduino.cc/]http://www.arduino.cc/[/iurl]
  Copyright (c) 2007 David A. Mellis
  This library is free software; you can redistribute it and/or
... bunch of stuff trimmed for posting ...
*/
/* modified for 2561 with fewer ports  RWP 2015 */
#ifndef Pins_Arduino_h
#define Pins_Arduino_h
#include <avr/pgmspace.h>
#define NUM_DIGITAL_PINS            46
#define NUM_ANALOG_INPUTS           8
#define analogInputToDigitalPin(p)  ((p < 8) ? (p) + 46 : -1)
#define digitalPinHasPWM(p)         (p==3 || p==4 || p==5 || p==12 || p==13 || p==14 || p==15 || p==45)
static const uint8_t SS   = 8;
static const uint8_t MOSI = 10;
static const uint8_t MISO = 11;
static const uint8_t SCK  = 9;
static const uint8_t SDA = 17;
static const uint8_t SCL = 16;
static const uint8_t LED_BUILTIN = 9;
static const uint8_t A0 = 46;
static const uint8_t A1 = 47;
static const uint8_t A2 = 48;
static const uint8_t A3 = 49;
static const uint8_t A4 = 50;
static const uint8_t A5 = 51;
static const uint8_t A6 = 52;
static const uint8_t A7 = 53;

// A majority of the pins are NOT PCINTs, SO BE WARNED (i.e. you cannot use them as receive pins)
// Only pins available for RECEIVE (TRANSMIT can be on any pin):
// (I've deliberately left out pin mapping to the Hardware USARTs - seems senseless to me)
// 2560: Pins: 10, 11, 12, 13,  50, 51, 52, 53,  62, 63, 64, 65, 66, 67, 68, 69
// 2561 PCINTs: 8-15, all on PORTB  - I DON"T KNOW WHAT TO DO HERE
#define digitalPinToPCICR(p)    ( (((p) >= 10) && ((p) <= 13)) || \
                                  (((p) >= 50) && ((p) <= 53)) || \
                                  (((p) >= 62) && ((p) <= 69)) ? (&PCICR) : ((uint8_t *)0) )
#define digitalPinToPCICRbit(p) ( (((p) >= 10) && ((p) <= 13)) || (((p) >= 50) && ((p) <= 53)) ? 0 : \
                                ( (((p) >= 62) && ((p) <= 69)) ? 2 : \
                                0 ) )
#define digitalPinToPCMSK(p)    ( (((p) >= 10) && ((p) <= 13)) || (((p) >= 50) && ((p) <= 53)) ? (&PCMSK0) : \
                                ( (((p) >= 62) && ((p) <= 69)) ? (&PCMSK2) : \
                                ((uint8_t *)0) ) )
#define digitalPinToPCMSKbit(p) ( (((p) >= 10) && ((p) <= 13)) ? ((p) - 6) : \
                                ( ((p) == 50) ? 3 : \
                                ( ((p) == 51) ? 2 : \
                                ( ((p) == 52) ? 1 : \
                                ( ((p) == 53) ? 0 : \
                                ( (((p) >= 62) && ((p) <= 69)) ? ((p) - 62) : \
                                0 ) ) ) ) ) )
#ifdef ARDUINO_MAIN
// bunch of stuff trimmed for posting ...
const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
 // PORTLIST  
 // -------------------------------------------  
 PE , // PE 0 ** 0 ** USART0_RX
 PE , // PE 1 ** 1 ** USART0_TX
 PE , // PE 2 ** 2 **  
 PE , // PE 3 ** 3 ** PWM0
 PE , // PE 4 ** 4 ** PWM1
 PE , // PE 5 ** 5 ** PWM2
 PE , // PE 6 ** 6 **  
 PE , // PE 7 ** 7 **
 
 PB , // PH 0 ** 8 ** SS
 PB , // PH 1 ** 9 ** SCK
 PB , // PB 2 ** 10 ** MOSI
 PB , // PB 3 ** 11 ** MISO
 PB , // PB 4 ** 12 ** PWM3
 PB , // PB 5 ** 13 ** PWM4
 PB , // PJ 6 ** 14 ** PWM5
 PB , // PJ 7 ** 15 ** PWM6
 
 PD , // PD 0 ** 16 ** I2C - SCL - INT0
 PD , // PD 1 ** 17 ** I2C - SDA - INT1
 PD , // PD 2 ** 18 ** USART1_RX - INT2
 PD , // PD 3 ** 19 ** USART1_TX - INT3
 PD , // PD 4 ** 20 **
 PD , // PD 5 ** 21 **  
 PD , // PD 6 ** 22 **
 PD , // PD 7 ** 23 **
 PA , // PA 0 ** 24 ** D24
 PA , // PA 1 ** 25 ** D25
 PA , // PA 2 ** 26 ** D26
 PA , // PA 3 ** 27 ** D27
 PA , // PA 4 ** 28 ** D28
 PA , // PA 5 ** 29 ** D29
 PA , // PC 6 ** 30 ** D30
 PA , // PC 7 ** 31 ** D31
 
 PC , // PC 0 ** 32 ** D32
 PC , // PC 1 ** 33 ** D33
 PC , // PC 2 ** 34 ** D34
 PC , // PC 3 ** 35 ** D35
 PC , // PC 4 ** 36 ** D36
 PC , // PC 5 ** 37 ** D37
 PC , // PC 6 ** 38 ** D38
 PC , // PC 7 ** 39 ** D39
 
 PG , // PG 0 ** 40 ** D40
 PG , // PG 1 ** 41 ** D41
 PG , // PG 2 ** 42 ** D42
 PG , // PG 3 ** 43 ** D43
 PG , // PG 4 ** 44 ** D44
 PG , // PG 5 ** 45 ** D45
 
 PF , // PF 0 ** 46 ** D46
 PF , // PF 1 ** 47 ** D47
 PF , // PF 2 ** 48 ** D48
 PF , // PF 3 ** 49 ** D49
 PF , // PF 4 ** 50 ** D50
 PF , // PF 5 ** 51 ** D51
 PF , // PF 6 ** 52 ** D52
 PB , // PF 7 ** 53 ** D53
 
};
// other similar tables trimmed for posting
#endif
#endif


Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

DrAzzy

#4
Oct 21, 2015, 10:00 pm Last Edit: Oct 21, 2015, 10:03 pm by DrAzzy
For the pin change interrupts, something like this shoudl work for your proposed mapping...?

Code: [Select]

#define digitalPinToPCICR(p)    (((p) >= 8) && ((p) <= 15)) ? (&PCICR) : ((uint8_t *)0) )

#define digitalPinToPCICRbit(p) (((p) >= 8) && ((p) <= 15)) ? 0 : ???? ) //What to return when it's not a valid pin? 0? In which case this could be shortened to 0.

#define digitalPinToPCMSK(p)    (((p) >= 8) && ((p) <= 15)) ? (&PCMSK0) : ((uint8_t *)0) )
#define digitalPinToPCMSKbit(p) (((p) >= 8) && ((p) <= 15)) ? p-8 : ??? ) //again, as above...


They take the pin number, and return the PCICR register (on some chips, this register isn't PCICR - the same functionality is on some general interrupt control register), and the bit within the PCICR register that controls enabling this PCINT. Likewise, the PCMSK ones return the PCMSKn register for a given pin, and the bit within that register for that specific pin out of the 8 it could be.
ATTinyCore for x4/x5/x61/x7/x8/x41/1634/828/x313 megaTinyCore for the megaavr ATtinies - Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

CrossRoads

Thanks, will see if I can pull it all together tonight and try a test compile.
You think the mapping is okay? I was thinking maybe match some of the Mega's, but the pins there are just all over the place where they left out stuff to make the IO fit the 70 pins they used for Serial, I2C, SPI, interrupts, and PWM, whereas I  am using all of them here. I kind of like the idea of complete contiguous ports too, altho that is easily addressed in software if one wants to use a whole part (direct port manipulation, or with arrays).
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

DrAzzy

#6
Oct 21, 2015, 10:18 pm Last Edit: Oct 21, 2015, 10:20 pm by DrAzzy
I like your mapping (and I also like being able to put whole ports onto consecutive pin numbers, with the pins right next to eachother) - they made a godawful mess out of the pin mapping on the mega, IMO. But my opinion probably shouldn't count for too much, since I don't use any AVR's that big (I haven't even used those 1284p boards you sold me - I assembled one, but didn't go beyond that - I don't know how people fill hundreds of KB of flash!

You've got at least one typo in that table (last line is PB should probably be PF), and multiple comments that haven't been adjusted, too.

ATTinyCore for x4/x5/x61/x7/x8/x41/1634/828/x313 megaTinyCore for the megaavr ATtinies - Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

larryd

#7
Oct 22, 2015, 12:52 am Last Edit: Oct 22, 2015, 12:56 am by LarryD
How about some LEDs.   :smiley-cry:

After this is made, create a mother board that this plugs onto (header pins or machined sockets).
Possible RTC, FTDI card, etc.
Headers for shields.

Diode across R30?
SDA/SCL/GND header?
Any need to add loading option resistor to the crystal?
Mounting holes in the four corners?

Edit: two header pins on reset where you can short to cause a reset
No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.

larryd

#8
Oct 22, 2015, 01:01 am Last Edit: Oct 22, 2015, 01:03 am by LarryD
Maybe have 5V and GND header pins to bring power onboard.
No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.

larryd

Might be wise to have a reversed biased diode +5 to GND to protect against reversed power supply connections.
No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.

larryd

#10
Oct 22, 2015, 01:43 am Last Edit: Oct 22, 2015, 02:03 am by LarryD
10uH between VCC an AVCC?

Edit:
It might be nice to have a TXD1 and RXD1 with GND (3 pin) header.
No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.

larryd

#11
Oct 22, 2015, 02:58 am Last Edit: Oct 22, 2015, 03:09 am by LarryD
Should have room for one of these smd switches for reset:


.
No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.

CrossRoads

#12
Oct 22, 2015, 06:02 am Last Edit: Oct 22, 2015, 06:07 am by CrossRoads
Ok, here's what I have now.
- Added Names per pins_arduino.h previously posted with PWM~, I2C, SPI, and Serial ports noted.
- Added Power LED
- Added SCK LED ("D13", but on D9 here)
- Added I2C header
- Rearranged Rx1/Tx1/Gnd so they are 3 pins in a row on the header
- (didn't do anything different for Rx0/Tx0 since they are on the "FTDI" header)
- Rearranged SDA/SCL/Gnd so they are 3 pins in a row on the header
- Added some more +5/Gnd headers
- Didn't add a Reset Switch - user can add one off board, or jumper one across ICSP header for debugging
- Added a Reset Diode
- Didn't add 10uH to AVCC. Too messy with Jumper to disconnect FTDI power from rest of board power.
- Didn't add reverse polarity protection.  Be careful. Also drops too much voltage if want to run from 3V, and somewhat with running from 3.7V, 4.5V (battery).
- Added 2mm mounting holes.
- Added pads for Crystal resistor. Have not seen the need for one any of my  boards yet so I do not plan to install one.
(these captures may differ a little as I tweaked things up)
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

CrossRoads

"Motherboard" concept, will have to work on that.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

CrossRoads

#14
Oct 22, 2015, 06:17 am Last Edit: Oct 22, 2015, 06:18 am by CrossRoads
Little tweak here:
Code: [Select]

mega2561.name=Arduino Mega 2561
mega2561.upload.protocol=wiring
mega2561.upload.maximum_size=258048
mega2561.upload.speed=115200
mega2561.bootloader.low_fuses=0xFF
mega2561.bootloader.high_fuses=0xD8
mega2561.bootloader.extended_fuses=0xFD
mega2561.bootloader.path=stk500v2
mega2561.bootloader.file=stk500boot_v2_mega2560.hex
mega2561.bootloader.unlock_bits=0x3F
mega2561.bootloader.lock_bits=0x0F
mega2561.build.mcu=atmega2561
mega2561.build.f_cpu=16000000L
mega2561.build.core=arduino
mega2561.build.variant=mega2561

Little tweak in pins_arduino.h, and it shows up & compiles Blink ok!
Code: [Select]

C:\Arduino\hardware\tools\avr\bin\avr-gcc -Os -Wl,--gc-sections -mmcu=atmega2561 -o
C:\Users\CROSSR~1.CRO\AppData\Local\Temp\build9182687107596139226.tmp\Blink.cpp.elf
C:\Users\CROSSR~1.CRO\AppData\Local\Temp\build9182687107596139226.tmp\Blink.cpp.o
C:\Users\CROSSR~1.CRO\AppData\Local\Temp\build9182687107596139226.tmp\core.a -L
C:\Users\CROSSR~1.CRO\AppData\Local\Temp\build9182687107596139226.tmp -lm
C:\Arduino\hardware\tools\avr\bin\avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0
C:\Users\CROSSR~1.CRO\AppData\Local\Temp\build9182687107596139226.tmp\Blink.cpp.elf
C:\Users\CROSSR~1.CRO\AppData\Local\Temp\build9182687107596139226.tmp\Blink.cpp.eep
C:\Arduino\hardware\tools\avr\bin\avr-objcopy -O ihex -R .eeprom
C:\Users\CROSSR~1.CRO\AppData\Local\Temp\build9182687107596139226.tmp\Blink.cpp.elf
C:\Users\CROSSR~1.CRO\AppData\Local\Temp\build9182687107596139226.tmp\Blink.cpp.hex
Binary sketch size: 1,556 bytes (of a 258,048 byte maximum)
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Go Up