If I have to use C++, what MCU should I use?

Thread Starter

bug13

Joined Feb 13, 2012
2,002
Hi guys

Some member properly know I am keen to transit to C++, so if I have to use C++, what MCU is suitable for this? I am assuming ARM?? Thanks guys!
 

shteii01

Joined Feb 19, 2010
4,644
Compiler will convert C++ to machine code. So. The original language (C, C++, Python, Assembly, whatever the eF you can come up with) DOES NOT MATTER.

Basically the only thing you need to ask is: "What IDE/program do I use to "write" code?"
By write I mean link and compile into machine code.

For you, find the IDE/program that does C++ and then look what mcu that IDE/program supports.

Take Arduino IDE. It does have some kind of C++ presence. So. If you pick Arduino IDE, you then lookup what mcu it supports, and here is the list: https://en.wikipedia.org/wiki/List_...ompatible_systems#Software-compatibility_only
Mostly ATmel, one SAM, several ARM from M0 to M4.
 

Thread Starter

bug13

Joined Feb 13, 2012
2,002
Compiler will convert C++ to machine code. So. The original language (C, C++, Python, Assembly, whatever the eF you can come up with) DOES NOT MATTER.

Basically the only thing you need to ask is: "What IDE/program do I use to "write" code?"
By write I mean link and compile into machine code.

For you, find the IDE/program that does C++ and then look what mcu that IDE/program supports.

Take Arduino IDE. It does have some kind of C++ presence. So. If you pick Arduino IDE, you then lookup what mcu it supports, and here is the list: https://en.wikipedia.org/wiki/List_...ompatible_systems#Software-compatibility_only
Mostly ATmel, one SAM, several ARM from M0 to M4.
The IDE I am using now is Code Composer and MPLab X, they both do C++, although I heard PIC32 is not very good. I generally use whatever free IDE/Compiler comes with the manufacturer.

Maybe I should ask better question, what architect (of MCU) is suitable for C++?
 

shteii01

Joined Feb 19, 2010
4,644
The IDE I am using now is Code Composer and MPLab X, they both do C++, although I heard PIC32 is not very good. I generally use whatever free IDE/Compiler comes with the manufacturer.

Maybe I should ask better question, what architect (of MCU) is suitable for C++?
Wrong question.
All the higher languages are converted to machine code. The compilers are written to match the architecture.

So. Pick a C++ compiler and see what mcu it supports. Or pick mcu and see what C++ compilers it has.
 

WBahn

Joined Mar 31, 2012
30,088
The fact that a compiler can generate code for an architecture isn't all the matters when talking about resource-starved systems. The overhead of supporting object-oriented constructs may simply be too great in order to get acceptable performance on such a system, regardless of the fact that the compiler can generate technically valid code for it.
 

shteii01

Joined Feb 19, 2010
4,644
The fact that a compiler can generate code for an architecture isn't all the matters when talking about resource-starved systems. The overhead of supporting object-oriented constructs may simply be too great in order to get acceptable performance on such a system, regardless of the fact that the compiler can generate technically valid code for it.
We sort of trust manufacturers and software companies to have a clue about their products.
 

nsaspook

Joined Aug 27, 2009
13,315
We sort of trust manufacturers and software companies to have a clue about their products.
and to supply customer demands for products. A large amount of embedded software is designed and implemented by people who are electrical engineers first and programmers looking for OOP purity far down the list. If there was actually a huge demand for highly optimized C++ products for smaller embedded systems then somebody would be making tons of money selling them.
 

WBahn

Joined Mar 31, 2012
30,088
We sort of trust manufacturers and software companies to have a clue about their products.
It's not a matter of whether the manufacturers or software companies have a clue about their products. At the end of the day they still have to live within the constraints imposed by the language and the architecture and that's not to mention the additional motivations to sacrifice optimal performance on a given platform in search of using common approaches that are broadly applicable to many platforms. Plus, don't forget that one of the key objectives in object-oriented code is to make it as hard as possible for the programmer to mess up by placing the burden on the compiler to do as much of the minutia. But the compiler doesn't know what is and what is not actually needed based on how the code will be used, so it has to cover all the bases unless it can determine that something isn't needed regardless of how the code is used.
 

shteii01

Joined Feb 19, 2010
4,644
and to supply customer demands for products. A large amount of embedded software is designed and implemented by people who are electrical engineers first and programmers looking for OOP purity far down the list. If there was actually a huge demand for highly optimized C++ products for smaller embedded systems then somebody would be making tons of money selling them.
Apparently op is part of that not huge demand.
 

nsaspook

Joined Aug 27, 2009
13,315
Apparently op is part of that not huge demand.
He's right from just the modern software engineering point of view of programming as the objective. However many micro-controller projects view programming as a necessary electronic circuit evil to make the uC hardware work with other hardware where you have a machine-interface mindset, think procedurally even if you write OOP inspired code, keep your code relatively flat to reduce stack/memory use, and keep it simple to enhance your debugging ability. Debugging hardware problems (like timing, real-time events, mysterious resets, etc...) makes or breaks embedded programmers in ways applications programmers rarely see.
 

Thread Starter

bug13

Joined Feb 13, 2012
2,002
So the answer to my question is no MCU should use C++?

I thought I could find something in the ARM M0-M4 series.
 

Thread Starter

bug13

Joined Feb 13, 2012
2,002
Just add to my last reply, I understand there is still limitations with C++ on an embedded system. And I am willing to learn how to write C++ in an embedded system efficiently.

The real time stuff will still be done on C, or maybe on a separated 8-bit MUC.

I am hoping to find a MCU that is suitable for using C++ (and a decent IDE). It’s mainly for applications code. Not low level hardware stuff.

Really don’t want to go to embedded Linux if I don’t have to.
 
Top