One day I had a college professor getting ready to teach us students a powerful mathematical trick in EE101 - mesh circuit analysis I think.  Before he got started he said, "Today, my students, I give you a BIG gun."  It got our attention and I remember the quote, but sadly, I'd be hard pressed to do mesh analysis today.

Today, my Instructible readers, I give you BIG guns!

For all you hardcore hot-shot embedded software programmers, time to step up to the next level by learning how to use an embedded realtime OS on your next project.  Not only do you get a priority based preemptive realtime OS, you also get all the goodies that go along with a realtime embedded OS like:  Tasks, Queues, binary semaphores, counting semaphores, recursive semaphores and mutexes for communication and synchronization between tasks, or between tasks and interrupts.  Gives me goose-bumps just thinking about it!  All this software power comes by way of FreeRTOS which has been around a long time.

Oh, and the hardware we're gonna run this on makes my head spin.  We're not talking little a Pic or Atmel micro.  No, no, we're gonna run this OS on a new 24MHz 32 Bit ARM® Cortex™-M3 from ST Micro.  The folks at ST Micro have made a development board, called the STM32 VL Discovery (VL is short for value line), available for $12 dollars!  They are probably selling the board at a loss.  For comparison, this board is about 1/3 the cost of a standard Arduino board.

The 24MHz STM32F100RBT6B micro that is used on the Discovery board is probably the slowest they sell.  Most of these chips run much faster!  However, the chip itself is not overly expensive - Digi-Key carriers the chip for $3.50 on orders over 100 pieces.  For $3.50 you get 128k flash and 8k RAM - no EEPROM needed since the micro can write to its own flash.

Below are the specs right off Mouser's web page for the STM32F100RBT6B chip:
  • Core:                                              ARM Cortex M3
  • Data Bus Width:                             32 bit
  • Program Memory Type:                 Flash
  • Program Memory Size:                  128 KB
  • Data RAM Size:                              8 KB
  • Interface Type:                                I2C, SPI, USART
  • Maximum Clock Frequency:            24 MHz
  • Number of Programmable I/Os:       51
  • Number of Timers:                          6
  • Operating Supply Voltage:              2 V to 3.6 V
  • Maximum Operating Temperature:  + 85 C
  • Package / Case:                               LQFP-64
  • 3rd Party Development Tools:          EWARM, EWARM-BL, MDK-ARM, RL-ARM, ULINK2
  • Development Tools By Supplier:      STM32100B-EVAL
  • Minimum Operating Temperature:    - 40 C
  • On-Chip ADC:                                  12 bit, 16 Channel
  • On-Chip DAC:                                  12 bit, 2 Channel
Just in case you think the ARM is not good for small projects, I did another search on Digi-Key and turned up an even less expensive ARM chip from NXP.  The NXP micro (Digi-Key part number 568-5142-ND) is another ARM Cortex-M0 chip.  However, the NXP chip runs at 50MHz (I'm getting more goose-bumps again), has 8k of flash / 2k of RAM, 28 IO on 32 pins, I²C, SPI, USART for (drum roll please) $1.46 @ 100pcs.  I love Moore's Law in action.

Learning this stuff has real application in the job market too.  Jabbering on about your latest Arduino project is not going to get much attention in an interview with an employer.  However, explaining how you solved a priority inversion problem on a embedded realtime OS will!  Trust me, I've interviewed / hired lots of embedded programmers over the years as a former Motorola employee.

Here is a link to purchase the STM32 Discovery for $12 bucks from Mouser.  Buy two just in case - the shipping cost is crazy so you might as well get two.  Oh, and the LCD in the picture also comes from Mouser ($12.50 each).


The OS we're going to use is called FreeRTOS and their web address is listed next.


Don't worry, you can use this OS in your commercial product without exposing your source code.  The OS uses a modified GPL license and is also royalty free.  For a complete breakdown of the license terms here is another link: 


The FreeRTOS realtime OS has been around for a long time and is very stable.  The OS has been ported to 26 different architectures and is very well documented.  I first used FreeRTOS on a product for GM.  My code, coupled with FreeRTOS, is running around in 10's of thousands of vehicles.  In those days, I used FreeRTOS on a Freescale Star12 chip (much less powerful).  I truly believe using FreeRTOS on that project saved my bacon.

Having the OS able to run on 26 different architectures, as I said before, does not mean your tied to a specific piece of hardware.  I like freedom of choice.  If you really want to dive in, I would suggest purchasing the book "Using the FreeRTOS Real Time Kernel - a Practical Guide".  The eBook version is only $25 bucks - buying the book helps the development of FreeRTOS too.  You can easily find the book at FreeRTOS.org.  Note, I have no financial interest in either FreeRTOS or ST - I just like both.

To keep up on future developments I'm working on you can always link to my RSS feed from my web site.  I try to post intermediate steps before I gather enough stuff together for an instructible.  My web site (Powerhouse Electronics) address is listed next:


For the RSS feed, add a "live" bookmark to:


Step 1: Software Tools

Getting a good build / debug environment setup seem to be more than half the battle.  This is really key in the long term.  Having a serious debugger is often overlooked when deciding on hardware.  Many of the low-end micros don't even have a debugger.  This forces the programmer to use printf statements and pin toggling to debug code. 

Anyway, seems like there are three choices when it comes to an IDE to program and debug the STM32 Discovery board.  I think all these IDE's are based on the Eclipse code base. The contenders are:
  • Atollic, LiteTrueSTUDIO
  • IAR, Embedded Workbench® for ARM
  • Keil, MDK-ARMTM
Each has limitations in terms of capabilities.  Only Atollic has unlimited code size and unlimited license duration.  Therefore, based on unlimited code size, I started developing with Atollic.  I've since learned, only one break point is allowed, there is a nasty pop-up ad that forces you to click "OK" after THREE seconds wait.  That nag ad comes up A LOT.  And strangely, it's almost impossible to change build settings without hacking XML code.  Still, once setup and running, I've had good luck with TrueSTUDIO.  Oh, and I got a quote on the "Pro" version from Atollic - the truly unlimited Pro version goes for $2,500 bucks.  To bad there is not a student version.  I would be willing to pay $100 bucks to get rid of that stupid nag ad!  Come on Atollic!  There must be a middle ground.

I'm not sure about IAR or Keil, but Atollic does not run on Linux.  Nor does it run under Wine, I'm told.  However, it does just fine running on Linux inside a VMWare virtual WinXP machine.  The screen-shot below shows WinXP running in a window with Atollic running inside that.  Total build time is 20 seconds after a "clean".  Not too bad.  Well, I guess it goes without saying, but I hear Atollic also runs OK on Windows too.  If you must.

The second screen-shot below shows the debugger in action.  The debugger inside the Atollic IDE works very well.  Everything works as you would expect.  There are also some video's that Atollic has made that show how to use the debugger to the fullest.  I've watched the videos twice already and will probably watch them yet again.  There is nothing more precious to an embedded software programmer than a powerful debugger!

Atollic makes downloading and installing TrueSTUDIO easy.  After you register they automatically email you a license key within a minute.  The windows installer is easy to use and quick.  The first time the software is run it will ask you for a "Workspace" location.  This is simply a directory where all your source code is located.  Note, there is also an easy way to switch to another workspace too.

<p>Hi Jim,</p><p>Thank you for this Instructable. This is great. I started on PicAXE years ago because my background was with VB and they offered a familiar language to program processors. Moved to Java &amp; Arduino and then to Teensy and variants thereof. A friend just put me onto the ST board, it's amazing for the price. I'm going to follow your 'ible to see if I can get up and running on both it and C++. </p><p>Can you recommend a source for libraries that I can use/experiment with? I want to replicate my Teensy build where I drive stepper driver boards to control stepper motors.</p><p>Thanks for the great write-up. I too can't understand why this is not more popular. I had to dig to find it.</p>
<p>what about .net micro framework. Have you tried that on STM32f4? </p>
<p>I've never used the .net micro framework. </p><p>My only experience, on a small micro, was with FreeRTOS. What I like most about FreeRTOS is how simple it is. Well, it's simple if there is a port to your particular micro. With FreeRTOS ported to your particular micro it's really easy to drop the source code into a project. With FreeRTOS complied into your project adding preemptive real-time tasks becomes a joy. For everything else, ST provides a big API library that can also be included into your project.</p>
Then if we increase the RAM...
Is it possible to use i386 and run windows xp embedded on it?
Nope, with only 128k of flash space there is no way. I have no idea what xp would need but 128k is way too small. Even my first IBM PC back in the 80's had a hard drive with 20Megs of space. That 20Meg drive is over 150 times bigger that 128k on this micro.
I'm amazed this instructible is not more popular!<br><br>First, the instructibles folks sat on it for a couple days. Then, once they decided to publish it they did so with a bunch of others. That push my instructible off the first page quickly. Plus, for some reason, they also failed to rate it in the &quot;editor's picks&quot;. With no star rating this instructible was doomed to poor ratings.<br><br>I also sent an email to Hack-a-Day trying to get them to pick it up. Nope.<br><br>Well, maybe it's just to technical for most folks.<br><br>It's not that I'm ticked off - I just thought this was really good stuff and I'm disappointed it got buried so quickly.<br><br>I don't get it,<br>Jim
I'm amazed the STM32 Discovery boards are not more popular. I have the same problem with my instructables; I think that once people see they are not based on an Arduino they simply put them in the &quot;too hard&quot; basket.<br><br>Thanks for the information on installing/running FreeRTOS. That is my next project for this board, I just need to think up an application.
Thanks for the kind words. <br><br>Yep, adding FreeRTOS on top of the STM32 board makes for an awesome combination. <br><br>Guess we'll just have to crank out some great projects to show the way.<br><br>Good luck,<br>Jim
Men you are GREAT !!!!<br><br>Im learning STM32 with a discovery kit and i hope learn how to use FreeRTOS with this projet... but setp by step.<br><br>Thanks again!!
<br> Thanks for the comments.<br> <br> There is more info on my web too.&nbsp; Have a look at: <a href="http://ph-elec.com">ph-elec.com</a><br> <br> Thanks,<br> Jim<br>
just looked at mouser and that board apparently costs $14<br>
Strange, I just look the part up at Mouser and they have it for $11.85 USD. The part number at Mouser is: 511-STM32VLDISCOVERY. Is this the same part number you used?<br><br>Thanks,<br>Jim
yups same part, i just looked and its now $13.13<br>think i gotta keep an eye and hope its chepest wen i can order one if i think its good for buying X3
Very strange, still shows $11.85 for me. I wonder if Mouser has a higher price because your from Norway. If true, that just stinks.<br><br>Note, the price has been $12 bucks at Mouser for many months.
most strange :/
Here is a link to a web page at ST. The page lists all the distributors, world wide. Hope this helps.<br><br>http://www.st.com/internet/evalboard/product/250863.jsp<br><br>
thanks i'll see wat it says for me
in the checkout its got:<br><br> MERCHANDISE TOTAL:<br> <br> $13.13<br>Delivery Charge:<br> $30.00<br> Order Total:<br> <br> $43.13 <br><br>thats a hell of alot for postage :/ totally put me off there<br>doesnt work out cheap at all<br>
The worst part is, ST (who makes the board) is head quartered in Geneva, Switzerland. Your board, from Mouser, probably would cross the Atlantic twice. There must be another distributor in Europe you can use. <br><br>When the board first came out ST advertised it at $10 USD.<br><br>Good luck,<br>Jim<br><br>
Thanks for the info, I want to try one of these.<br><br>Just ordered 2.<br>$10.34 each currently at Arrow<br>Shipping and tax was $9.40 though

About This Instructable


39 favorites


Bio: Founder of Powerhouse Electronics. For more info goto: www.ph-elec.com
More by jimk3038: Easy ESP8266 WiFi Debugging with Python Raspberry Pi Internet Weather Station Make Your Own Laser Cut Standoffs for Electronic Projects
Add instructable to: