Electronic – How to start with STM32F103C8T6 board

armmicrocontrollerstm32

I have been using an 8-bit AVR MCUs to build line-follower robots with students for a few years now. Now I would like to step up to an ARM Cortex-M3 because I'd like to add some more CPU-intensive features like odometry and sensor fusion.

The requirements are:

  • 8 analog inputs,
  • 4 PWM outputs,
  • I2C,
  • 2 quadrature encoder inputs,
  • serial I/O,
  • Self-programming wirelessly without physical access
    to the robot.
  • Multiplatform toolchain + IDE (OS X, Linux, Windows).

The steps I've taken so far are:

I'm using this STM32F103C8 based board. I believe this MCU has everything I need, including the 2 x QEI which I planned to implement in software but this one happens to have it in hardware, so great:

I've followed this to set up my toolchain + IDE:

I've found that the documentation for this chip is scattered among a number of PDFs, which I downloaded:

I also downloaded the STM32F10x standard peripheral library, but that in turn recommended me to get the newer STM32CubeF1, which I believe is just a marketing rename of the above, so I got both:

Finally, I've also got "The Definitive Guide to the ARM Cortex-M3" by Joseph Yiu, which I'm reading as I wait for the boards to arrive.

My questions are:

  1. I'm a bit overwhelmed by documentation, to say the least, and I'm not even sure I got it all. For example, the datasheet and the reference manual state that the chip has 3 timers capable of quadrature encoded inputs. But, I can't find documentation of the registers that control the timers anywhere in the PDFs above. What am I missing?

  2. Should I use the (older?) Standard Peripheral Library, or the (newer?) cube thing? What's the difference? I understand that both libraries save me from manipulating registers directly and are the recommended way to go. Am I right?

  3. Where is the documentation for the libraries (besides the embedded doxygen comments, which are nice and all but I'd rather have a searchable html/pdf)?

  4. I chose Eclipse + GCC ARM + OpenOCD as my toolchain because I consider this is the only option that will run on the 3 main OSes without code size or other limitations. Are there any more options?

Best Answer

  1. As it comes to datasheets they are indeed divided. "Reference manual" is complex descriptions of how to do things, configuration and detailed considerations about the whole MCU. "Datasheet" is on the other hand only a brief description of MCU features, pinouts, packages etc. There is also very helpful document for every STM32 line (F1,2...7) "Getting started with STM32F7xxxx MCU hardware development" which provides you with many informations if case you would like to design a custom board. In comparison to AVRs, registers descriptions are sometimes put a bit aside from main description of particular chapter.

  2. STM32CubeMX is not a library, just a useful program from ST, which enables you to set pinouts, its configurations, set systems clocks etc and then, at the end, generate a code and the whole project. The project can be generated specially for Eclipse (System Workbench for STM32) in which you just import this project and you're ready to go. The new library is HAL ("hardware abstraction layer") and try to use it. That's the new thing and sometimes it's hard to find examples on the Internet but don't teach your students outdated technologies. HAL is convenient to use and has documentation, so I think it's better choice.

  3. Which library? Anyway it shouldn't be a problem to google them, I think.

  4. Even if you would like to use only one OS (like Windows), Eclipse (AC6 = System workbench for STM32) is - I think - the best option. There is for example Keil's uVision 5 - but that's really terrible IDE - it lacks most of features IDE should offer (refractoring, click-and-search, proper error checking, finding references and many, many more). So, all in all, the Eclipse is pretty much the only reasonable choice for IDE for STM32.