Code Interoperability -- ATMEGA324PA <--> ATMEGA1284P
Starhawk wrote 11/16/2017 at 01:08 • 0 pointsI'm trying to build a thing (namely, https://hackaday.io/project/75-z80-microcomputer-system) and the original dev is rather busy and can't answer questions as fast as I'd like. (In related news, I'm an impatient f***. At least I know it!)
Within that design for that retrocomputer at that link, is an ATMEGA324PA microcontroller, tasked with operating the system's video, keyboard, RS-232 (except level translation), and IDE interfaces as well as some low-level timing stuff.
I have a complete build, which I kludged into the bottom half of a Commodore 1571 housing that still had the drive's power supply intact. (For the record, the previous owner of the, er, drive had removed the mechanicals and scrapped out the logic board due to an issue with said mechanicals that apparently wasn't worth the trouble to repair.) In doing so, and wiring it up to run off said supply, I uhm accidentally reversed the rails, putting 12v through the board instead of 5v.
Oops.
I now have a quite thoroughly deceased ATMEGA324PA (internal short... good for making hot chocolate, now, but not for anything electronic...), along with potentially other damage -- which I can't troubleshoot (or even really discover) until I replace the microcontroller, because its timing aspects, which I mentioned earlier, include driving the CPU clock...
Herein lies the problem. '324PAs are essentially unobtanium right now. eBay wants a fairly princely sum, and there's only one seller with the part, and he's in China. Mouser is out of stock until December 1 at the earliest. Digikey wants $20ish for two with Priority Mail shipping, or a bit more than $16 for one.
At this point I'm running out of swear words, as well...
HOWEVER... I have two ATMEGA1284P chips sitting on dev boards that I'll never ever ever use. I checked, and the pinout is identical, so /physically/, the chips are drop-in replacements for each other. I don't have the source code for the '324PA -- at least, if I do, it's not in any form I can recognize and therefore use. BUT the ZIP archive, on that linked page way up at the beginning of all this, has a *.hex file that is what I need for flashing the '324PA. I have a TL866x programmer, too, and the software to make it dance.
What I *DON'T* know, because I'm no coder, and thus ultimately what I'm asking the HaD[dot]IO community here, is -- is the 1284P interoperable with the 324PA enough inside (i.e. in terms of code) that I can just throw that *.hex file (and the fuse settings) at one of my 1284P chips and have it, like, just work? or does the code need to be specifically compiled for the different chip...?
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.
Comment from Microchip --
"Thank you for contacting Micrcochip technical support team.
Same code should work, but our recommendation is to recompile code before using for another variant of the same device.
I have attached your fuse setting description from the Atmel studio program.
Since you are using third party tools we cannot comment on that part."
Yaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaay that's what I was hoping to hear.
Are you sure? yes | no
The 1284P chip took the unaltered code and fuse programming without errors... I have not tested it in-circuit yet, though -- that's next, after lunch...
Are you sure? yes | no
Test failed, but it could be other chips on the board. Not sure yet.
Are you sure? yes | no
I've asked Microchip (aka the fish that ate Atmel) this question... I'll post their answer when I get it. As they're a large corporation and this is third-party code, I'm not expecting a useful answer... probably something along the lines of "we can't guarantee anything" with no further info. So if anyone wants to chime in... chime in, dangit!
Are you sure? yes | no
I don't have any AVR-specific experience, but it won't work out of the box, for sure.
Register locations and other memory layout differences will prevent that from working.
Additionally, how peripherals work will be different.
Even if you had the code and recompiled for your target architecture, it wouldn't work without some modifications. That may solve the memory location problem, but not peripherals.
Are you sure? yes | no
Dude, they're in the same /series/ of chip. If you're not familiar, please /at least/ read the datasheet (it's the same one for both) before speculating... that's what I'd do, at minimum...
Are you sure? yes | no
I'm sorry I tried to help.
Your answer from Microchip will be no different.
Are you sure? yes | no
No, no no. I apologize myself, I've been entirely too brusque, and a bit rude, to boot. /I'm/ sorry. I should not have said what I said.
I do appreciate that you chipped in -- it's just that, after looking at the unified datasheet that covers both chips (and a few others) -- your answer doesn't make sense to me. It's the same architecture on both chips, AFAICT. I admit to a limited understanding myself, but from what I can tell, the 1284P is simply a "bigger" 324PA. But -- I could be quite wrong about that.
Tell you what. You know more than I do, probably, even if I can't understand why they'd be so dramatically different. Here's the datasheet -- http://www.atmel.com/images/Atmel-8272-8-bit-AVR-microcontroller-ATmega164A_PA-324A_PA-644A_PA-1284_P_datasheet.pdf -- if you have the time and inclination, could you check and make sure whether the only real differences are the amount of memory and that IIRC the 1284P has an extra timer somewhere, or that there really ARE significant differences in the implementation and that things have to be recompiled...?
Are you sure? yes | no
I find that in most cases, as long as both chips have the feature it will work the same even across different Atmel product lines. Sometimes it doesn't. But it usually does.
I spend way more time cleaning up warnings left by sloppy programmers than actually porting anything. :)
The same is true on a lot of the TI chips.
It might even be broadly true for companies that make it easy to use an open source toolchain! They naturally standardize themselves internally.
Are you sure? yes | no
ARGH. This shouldn't be a hard question.
Somebody want to help...?
Are you sure? yes | no