Can i use a code written for one MCU to be used on another MCU.

Thread Starter

lord_K

Joined Apr 24, 2019
16
i have a code written for atmel atmega2560. currently it is used on that MCU. now i am upgrading the MCU to 32 bit, So that i could establish communication via usb protocol. Because in the whole system the speed is very low. now can i use the same code written for atmega2560 to run on 32 bit MCU's with some necessary adjustments regarding USB protocol. The MCU is not yet decided.I cannot figure out which MCU might be best suited for this kind of job.No extra job is added, just USB protocol will be implemented. I am a bit inclined towards stm32 series but i donot have have an idea, how much code variation will be there. Also AVR32UC3 family is an option because atmel atmega2560 is AVR and AVR32UC3 is also AVR. also ethernet protocol will b implemented afterwards.
 

Sensacell

Joined Jun 19, 2012
3,452
Code is what language?

If it's a compiled language, the code can be compiled for another machine.

But... the significant hardware differences will make it almost impossible to get it to work.
 

BR-549

Joined Sep 22, 2013
4,928
No. It's too big of a processor jump. You could copy high level(C) routines.....but the new chip house keeping and overhead will be different.
 

Ian Rogers

Joined Dec 12, 2012
1,136
If it was written on the Arduino platform, you will have no problem at all. But if you are assembling... It'll take a while, If it is in C, then a tad quicker.. If you have written with forethought ie.. used labels and symbols you can convert very quickly..

I have a tendency to work on specific hardware and hard code a little more than I should " Sucks to be me if I upgrade"..

I have written for the 2560 on the Arduino, when I swapped to the Pic32 using that platform, not one piece of code needed changing.
 

Thread Starter

lord_K

Joined Apr 24, 2019
16
If it was written on the Arduino platform, you will have no problem at all. But if you are assembling... It'll take a while, If it is in C, then a tad quicker.. If you have written with forethought ie.. used labels and symbols you can convert very quickly..

I have a tendency to work on specific hardware and hard code a little more than I should " Sucks to be me if I upgrade"..

I have written for the 2560 on the Arduino, when I swapped to the Pic32 using that platform, not one piece of code needed changing.
what do you mean by ''not one piece of code needed changing''.. you mean it is possible to just change something in it and use it on any other usb and ethernet capable MCU. can you name such kind of MCU
 

BR-549

Joined Sep 22, 2013
4,928
Few things are absolute. And it depends on the actual context of the question. Which usually changes thru-out the thread as more details come along.
 

Ian Rogers

Joined Dec 12, 2012
1,136
what do you mean by ''not one piece of code needed changing''.. you mean it is possible to just change something in it and use it on any other usb and ethernet capable MCU. can you name such kind of MCU
Please re-read my post... On the Arduino platform!!! I'm not talking about general programming.. This platform takes the device out of the equation, they use generic hardware profiles and the code is totally portable TO OTHER ARDUINO supported hardware.

Most MCU's are now supported ST32 Pic32 etc....
 
Top