Quantcast
Channel: ARM Connected Community : All Content - All Communities
Viewing all articles
Browse latest Browse all 6005

Run Ada programming language on ARM Cortex-M4

$
0
0

Bill Wong over at Electronic Design magazine has a nice one-page article about running Ada on the ARM Cortex-M4 microcontroller core. Ada is a big-iron programming language developed for the US military. It strives to be maintainable. It also strives to be understandable, using "or else" and "and then" rather than "||" and "&&." Note that is started life intended for embedded systems, back in the 1980s when military contractors were using dozens of languages and the military got fed up and mandated Ada.

Ada_Lovelace_portrait.jpg

The Ada programming language is named after Augusta Ada King, Countess of Lovelace, who described programs back in 1843 for the Babbage Analytical Engine, the first, albeit unbuilt, mechanical digital computer.

 

If Pascal is golden handcuffs, Ada is full body armor, meant to protect the programmer from variable type problems, and with little pleasures like named loop closing, “end if” or “end loop”, so your nested conditionals don’t become rat’s nests. Ada is meant to be maintained, and not just by the guy that wrote it. As someone who just took his 1962 Sportster out for a ride, I really love programming languages that are meant to be maintained.

 

Bill Wong’s article gives a code example, which I won’t plagiarize; you should check it out to see how Ada reads and is parsed. Wong does note:

“I’ve used C and C++ almost since their inception. I admit to incorporating more than one unwanted bug into C applications that were eliminated after sometimes tedious diagnostic sessions.” And “I prefer the more verbose if/then/else conditional expression of Ada to the C/C++ ?: combination. I have programmed in APL, and its one-liners were neat but typically indecipherable. C and C++ code can get this way too.”

I note that young engineers really get a kick out of being able to read and write what looks like gibberish. They like programming languages that are cryptic and arcane. It makes us feel smart—we get it, we know the code. But when we get older, we all have to look at something we wrote in college, or in my case, a stepper motor wafer elevator program I wrote 6 months before. Then you want something that is more apparently understandable. When I wrote that little program to run motors and watch opto-flags, I dashed off all 200 lines and was naive enough to think it would compile and run. How about a couple more days of 3 lines at a time, until I finally got it debugged. I looked at the code 6 months later and at first glance, had no idea what I had done or why.

 

This is where Ada helps, both in writing things that will compile and letting other people understand what you are doing at first glance, even if they are a hardware guy like me. And a lot of embedded engineers do both the hardware and software.

 

Atmel-SAM4S-Xplained-Pro.jpg

The Atmel SAM4S is built around an ARM Cortex-M4 core, and comes on this Xplained Pro demo board, which includes a debugger interface.

 

And while Wong uses a Cortex-M4 from honored Atmel competitor STMicro, I want to point out Atmel has a whole slew of M4-based micros. Everything from the stripper SAM4N with a megabyte of Flash, to the SAM4E Ethernet, to the SAM4P low power, to the SAM4S scalable to 2MB of Flash.,to the SAM G53 with a floating point unit. I am pretty sure that will hold your Ada code, and run with the speed and low power typical of all the ARM cores.

 

Victor Hugo wrote “If a writer wrote merely for his time, I would have to break my pen and throw it away.” If you are dashing off flappy bird code, or doing consumer work where every penny counts and you have use the smallest memory parts available, script kiddie stuff or C or assembler are just dandy. But if you are writing rock-solid industrial or military or automotive applications that have to work right, be dependable, and be maintained for decades by people that might not even speak English, well then check out Ada. It might have a price for more memory, but the cost will be much less in the long run.


Viewing all articles
Browse latest Browse all 6005

Latest Images

Trending Articles



Latest Images