STM32F4 Cortex-M4 is bonkers, and I want one

I posted at LeafLabs about ST Micro’s recent release of their ARM Cortex-M4 implementation, the STM32F4, but forgot to post here. I am a geek. I love computer hardware, and microcontrollers are great because I can afford to get them and try to make my own computers.

What could be more fun? Oh, yea, you have  a long list. Okay, let me press on.

There are a few things which microcontroller fans might like about ST Micro’s new product:

1MByte Flash, and 192KBytes of RAM. I remember reading the Unix edition six source, and IIRC, it would run in 128KBytes RAM, and that was a multi-user , multi-process operating system, with a proper hierarchical file system (none of the A: nonsense). That amount of memory is quite luxurious for Arduino users. It is 32 Arduino UNO’s worth of Flash, and 96 Arduino UNO’s worth of RAM.

Floating Point Unit. Modern PC’s have hardware floating point. For some problems, it is much easier to write a solution using floating point numbers than whole numbers (integers). For example manipulating angles, or digital audio signals. A floating point number is one with a decimal point, like 3.1415926, or that is tiny, like 10^-126, a number which makes a yoctosecind seem like an eternity (seriously, the age of the universe, measured in yoctoseconds is only 4.3×10^41 yoctoseconds), or big, like 10^127 (that’s the digit 1, with 127 zero’s after it).

The nifty thing about floating point numbers is they keep track of the position of the floating point for you. Most microcontrollers don’t have floating point hardware, so programs have to do all the bookkeeping and arithmetic in software. You don’t have to write the code because the compiler will do that for you. This can be a bit weird because it looks just the same as integer arithmetic, but the program is bigger and slower.

ARM publish a few benchmarks which suggest Cortex-M processor with hardware floating pont might be 10x faster than the same processor doing floating point arithmetic in software.

That is quite a big deal, if you want to use something like trigonometry, where calculating sine or cosine are themselves a bunch of floating point calculations. We really might see that 10x speed change.

Why do I care? Well, I am very interested in things which might inspire and motivate children and adults to learn programming. Sound and music are an area that lots of people love. Simple notes can be described by sine curves. So it would be very handy to write simple programs which generates values on a sine curve, and pumps them out through a Digital to Analogue Converter (DAC), through an analogue audio chain, so that we can hear it.

Something like:

const float frequency = 440.000; // A above middle C
const int sample_freq = 44100; // CD audio sample frequency, 44.1KHz
const int samples = sample_freq/frequency; // number of samples/cycle
while (true) {
    for (int i=0; i<=samples; i++) { 
        dacWrite( sine(i * 2.0*PI / samples) ); 
        delayMicroseconds(1000000/sample_freq); 
    }
}

That is too rough to work well (the delay might not be accurate enough, and it ignores the time used to do the calculation and loop) but I hope it is enough to illustrate the idea. Fast floating point should make maths and music easier to program.

STM32F4DISCOVERY is the low-cost development kit that STM are offering. Farnell are taking pre-orders, it is £9.26+VAT! They are about $16 in the USA, but I didn’t see any distributors with the stock-arrival date.

That is an amazing price if you were to compare to something that has to be sold at a profit, like an Arduino UNO. Of course ST Micro don’t have to make a profit on this, they might regard it as the cost of a marketing campaign. I much prefer this approach to a fancy, glossy, high visibility marketing campaign. I don’t want to look at fancy ads. I want the product at a price which I can’t ignore. Thank you STM.

I’ll try to pick up again, and mention some of the other nifty stuff, but if your interested, please check out the datasheets and reference manual.

About these ads

6 Responses to “STM32F4 Cortex-M4 is bonkers, and I want one”

  1. Erle Czar Mantos Says:

    Any chance you might post some tutorials about developing for the stm32f4 with open source tools?

    The development tools they are “suggesting” are quite pricey.

    • ourduino Says:

      Erle, I am going along to a free one days hands on event run by http://www.silica.com/events/seminar-list.html
      So I hope to find out more then, and will report back.

      I would much prefer to use an Open Source toolchain, preferably gcc. I very much want people to be able to use microcontroller technologies with the minimum of obstacles.
      LeafLabs bundle up gcc with their IDE for Maple. LeafLabs have posted on their forum that they have an STM32F4 development board, so I am hopeful that they might check it out.
      I believe that gcc will generate code that will run on the STM32F4 now. I don’t know how well that uses the Floating Point Unit, and whether or not it generates machine instructions for some of the other hardware features like Single Instruction Multiple Data (SIMD).
      So plenty to learn :-)

  2. Michael Shimniok Says:

    Wow, that little bugger packs a punch! Now I want one too. Great, more microcontrollers, as if I weren’t swimming in myriad types and models already :)

    • ourduino Says:

      “So many microcontrollers, so little time”:)

      I hope that this one will make it even more straightforward for people to make amazing projects.
      I expect this one will able to run an ordinary MP3 decoder (using floating point), and hopefully an Ogg Vorbis decoder.
      It would be nice to have an Open Source hardware and Open Source Software music player :-)

  3. Richard Dudley Says:

    I want one too! But nobody has any stock so they’ll be back ordered for weeks if not months…. Perhaps NXP’s Cortex M4 will come out before this ships!

    • ourduino Says:

      Richard – I ordered my STM32F4DISCOVERY development boards from Farnell on the 28th of September, and the “stock due date” is still counting down. Today it is saying 8 days to delivery, which may mean 14th October. We will see.

      Also, Future Electronics were listing a STM32F407IGT6 part as in stock yesterday (still there today). There are only 200, so they will probably go quickly. It has 176-pins, which is more than I need. It has 1MByte flash, 192KByte RAM, and is priced at $9.30 each, one off.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.

%d bloggers like this: