Author Topic: Compatibility between ATMega types  (Read 2120 times)

0 Members and 1 Guest are viewing this topic.

Offline Dan MoosTopic starter

  • Frequent Contributor
  • **
  • Posts: 359
  • Country: us
Compatibility between ATMega types
« on: February 02, 2017, 04:42:14 am »
I have a hobby project that I've been working up on a ATMega328. For mainly SRAM reasons, I'm moving the project to an ATMega1284.

I'm curious if, besides features/pins that they don't have in common, will my code work unchanged? I am specifically curious if  I2C library I wrote will work without needing changes.

I realize that the two parts have different internal oscillators, and will make the appropriate changes.

Also, the 328 uses debugWire, whereas the 1284 uses JTAG. Any capabilities that JTAG offers over debugWire that I should know about? I'm programming/debugging with an AVR Dragon.

Thanks!


Sent from my E6830 using Tapatalk

 

Offline Kleinstein

  • Super Contributor
  • ***
  • Posts: 17297
  • Country: de
Re: Compatibility between ATMega types
« Reply #1 on: February 02, 2017, 04:40:36 pm »
The newer ATMega are very similar. So the mega328 code should also run on the mega1284. It is only the older ones, like mega8, Mega16 that were a little different, though much of this is only a different name convention - so even there things were rather similar, just got different names.

AFAIK JTAG has a few extra functions and thus should be a little more powerful than debug wire.  Also the JTAG pins are usually active for JTAG. So if you need the JTAG pins as a normal IO, you have to disable JTAG first.
 

Offline obiwanjacobi

  • Super Contributor
  • ***
  • Posts: 1030
  • Country: nl
  • What's this yippee-yayoh pin you talk about!?
    • Marctronix Blog
Re: Compatibility between ATMega types
« Reply #2 on: February 02, 2017, 04:56:45 pm »
Yes, big chance it works after a recompile (with the new target).

The register definitions are usually named the same in the header files across a wide range of ATmega devices.
The 1284 is nice, did a project with that too. If you're still short for IO try the 128 instead, it pretty big (and cheap on ebay - last time I looked) but in QFP package, not a DIP.

Wrong code should not compile!
 

Offline krho

  • Regular Contributor
  • *
  • Posts: 233
  • Country: si
Re: Compatibility between ATMega types
« Reply #3 on: February 02, 2017, 06:17:09 pm »
Can't cay for atmega, but whole XMEGA A-E series is compatible. Unless you go down the family chain towards E series and use something that that doesn't have.

however going from atmega to xmega requires some work, as peripheral structures are differently named also the flags. Bot To mee they seem more sane than the ones in atmega.
 

Offline Rick Law

  • Super Contributor
  • ***
  • Posts: 3538
  • Country: us
Re: Compatibility between ATMega types
« Reply #4 on: February 02, 2017, 08:25:29 pm »
This is the ATTINY line, but ATMEGA line may also have the same.  Some of the bit settings for various register may be different between chips within the same product line.

I recall I had a hard time doing either a adc timer or PWM (not recall clearly which, one of them.)  Between the Attiny 13, 25, and 85, they all have the same bits controlling the same feature but they are at different positions in the byte.  After verifying the bits are there between them, I didn't catch that one control bit was at a different position during the initial coding.  I had a hard time debugging that later.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->