Tag Archives: STM32


Porting ST Standard Peripheral Library (SPL) with MikroC PRO for ARM

What is this Standard Peripheral Library (SPL)?

It’s just a collection of hardware libraries that provide an easy approach to any STM32 ARM programmer. It has support for every peripheral a STM32 micro has like CAN, USB, ADC, Timers, etc. In short it’s a hardware abstraction layer fully covering the STM32.

Why use the ST SPL?

  1. Reduce coding time by spending less time figuring out 32 bit register values and going through a near thousand page reference manual.
  2. Take the advantages of the built-in code library of MikroC which other compilers don’t offer.
  3. SPL is used by most STM32 ARM programmers and so it is a widely used tool with a large community.
  4. Most books and documents on STM32 ARMs are based on SPL.
  5. A compiler like MikroC doesn’t give full focus towards STM32. It has other ARM concerns like TI’s TIVA, NXP, etc and so MikroC’s built-in libraries are not 100% compatible with all ST hardware.
  6. Following the previous point MikroC (at least at the time of writing this article) doesn’t give library support for hardware like the DMA and so there’s incompleteness to some extent. It is also worth noting that depending on MikroC’s library also has the disadvantage of code size and efficiency. It is in general true for every compiler. However MikroC’s IDE is cool enough to do things with ease and that’s why I like it. Unless you are a Maple or Arduino fanboy, you’ll get my point.

Software Needed

  1. Modified ST Standard Peripheral Library (SPL) as supplied here: STM32 Standard Peripheral Library for MikroC. It works for STM32F10x micros only.
  2. MikroC PRO for ARM compiler.
  3. Flash Loader Demo or ST-Link Programmer Software.

Hardware Needed

  1. A STM32F10x Development Board.
  2. A USB-Serial Converter or ST-Link Programmer.
  3. Some basic components like a mini bread board, connecting wires/jumpers, a LED, a 220Ω 0.25W resistor and a push button.
  4. Optional debugger hardware.

How to use the Standard Peripheral Library?

First we need to prepare our MikroC PRO for ARM compiler for linking with SPL. I’m assuming that the compiler is preinstalled. First go to the compiler’s installation folder and look for the include folder. In my case, it is:
C:\Users\Public\Documents\Mikroelektronika\mikroC PRO for ARM\Include.

In this folder there’s a file named stdint.h. It’s basically a definition of variable types and other related stuffs. Rename it to stdint (backup).h and copy the new stdint.h file from the supplied folder to this location. We are done here.

stdint modification

Read more

STM32 – Prior to Start

STM32 ARM-based micros from STMicroelectronics pack high density resources than any other conventional microcontroller. They are also high speed devices, operating typically at 72MHz and beyond. Despite several advanced features and heavy resources, they turn out to be misfortunes for beginners who wish to play with them. Available in market are several cool STM32 boards but most of them are not well documented. The aim of this document is to address some common FAQs.

Typically most people ask the following question:

  • How to program the STM32 micro embedded in my development board?
  • What tools do I need to get started?
  • What compiler support do I have for STM32?
  • What resources are available for STM32 on the internet?

In this doc, I’ll be addressing these FAQs along with some basics as I had similar questions in my early expeditions with STM32 micros. When I started with STM32 these questions were there as they are now. Literally there was nothing to address them till now. Most experts take it for granted that those who are beginning with ARMs must have heavy knowledge on the topic and thus skip answering these simple or silly questions.

Well I decided to break this stalemate for any starter no matter what’s his/her experience. Firstly most people nowadays believe ARM is only for mobile phones, PDAs, tablets, etc. and can’t be used like other micros like AVRs and PICs. This is completely wrong. Firstly because no one has set such a rule and secondly because there’s no limit to requirements in an embedded design. However it would be wasteful to make simple LED blinking stuffs with such chips. When it comes to size and resources ARM varies in all aspects. You can have an ARM chip with similar resources available in a typical 8 bit or 16 bit micro and yet you can also have an ARM chip with high resources. For instance if you think of flash memory, an ARM chip can have a few kilobytes to several megabytes of flash memory. Thus not just for real-time operating systems, phones, DSP, graphical processing and so on but also for other kinds of embedded systems the door for ARM is always open. It’ll completely depend on its user. STM32 portfolio has wide ranges of 32 bit ARM micros just as I described. A quick look on ST’s page will give you a brief idea: http://www.st.com/web/en/catalog/mmc/FM141/SC1169 .

Answering from the last, let’s see what resources are available for STM32s on the internet. Going back to ST’s site one can clearly see that there are several app notes for STM32s. At the time of writing this doc there 83 app notes on ST’s page. Obviously then there are reference manuals, datasheet and other docs too. Of these the important ones are the datasheet of a particular micro and its family reference manual. The rest of the stuffs are various software and tools but here confusion arises. We’ll see what other things are needed later but for now let’s see the purpose of reference manuals and datasheet. The reference manual is needed for understanding the internal hardware of a particular STM32 family, the registers associated with these hardware, programming techniques and what “not”s and what “are”s. These make it the core document of all. Datasheet basically give overviews of the devices. Books available for STM32-based ARMs are hard to find but still found a book called Discovering STM32 on Google search’s first page.

Regarding compiler selection, there are several available for STM32 micros. The most common ones are Keil, CooCox and MikroC PRO for ARM. My personal favourite is MikroC (http://www.mikroe.com/mikroc/arm/) as I’m already familiar with MikroC for AVR and 8051. MikroC comes with lot of easy-to-use built-in and examples and so it’s a good compiler to work with. Anyone familiar with MikroC will not have any trouble using it for ARM. With MikroC one can go to raw levels and he/she can also go for easy library-based coding.

Now let’s see what tools we’ll need for STM32 micros. The first tool we’ll need is called Flash Loader Demonstrator (http://www.st.com/web/en/catalog/tools/PF257525).  Basically it’s a programmer GUI based on factory loaded bootloader that allows a user to load, erase, verify, read or set configuration bits for his/her STM32 micro. The second tool is called Microxplorer (http://www.st.com/web/en/catalog/tools/PF251717). This tool allows a user to graphically set configurations for IO ports, internal hardware and many more. Basically it’ll help you reduce your time debugging registers. Both of these software are free and easy to use.  The last but not the least tool is called Timer Calculator (http://www.libstock.com/projects/view/398/timer-calculator). It’s a handy tool for those who’ll use MikroC for ARM. It can be used to generate codes for timer interrupts and timer-based stuffs. There are other tools too.

The final topic is about loading code to a STM32 micro. There are two ways either by a JTAG programmer like ST-Link or by bootloader and UART. The former is the best choice as it is a programmer and a debugger but in terms of expense this is unnecessary as the chips come with preprogramed bootloader. Thus the latter method of using bootloader and UART is simplest and also the most popular solution. This is also my personal preference as I didn’t want to spend for another programmer just for the purpose studying. This is the method I’ll describe here. Let’s see the board:

Untitled

Read more

FlowPaw: A new rapid prototyping tool for electronics and robotics

With so many other development platforms already out there in market, DSP Robotics, in collaboration with MikroElektronika, is going to introduce a new tool, FlowPaw, for rapid prototyping with electronics and robotics. FlowPaw is an expandable development board that carries a STM32F415RG MCU and four mikroBUS™ sockets, which provides a simple Plug-and-Play solution for connecting mikroElektronika’s several dozens of accessory boards called Click Boards. The Click boards are available for a wide range of applications including GPS, WiFi, MP3 decoding, Bluetooth, CAN, IrDA, GSM, and Ethernet. The FlowPaw is programmed directly through a PC USB port using FlowStone, a drag-and-drop programming tool. For those who are interested in getting a first-hand experience with FlowPaw, DSP Robitics is currently running a crowdfunding campaign over Kickstarter.

FlowPaw main board

FlowPaw main board

 

New STM32 Nucleo development boards are mbed-enabled and support Arduino connectivity

STMicroelectronics reveals affordable, extensible platform called STM32 Nucleo for efficient prototyping with STM32 Microcontrollers. The STM32 Nucleo development boards are mbed supported, and have Arduino pin headers on board so that the tons of existing Arduino shields can be easily used with these boards.

STM32 Nucleo board

STM32 Nucleo board

The new STM32 Nucleo boards are mbed-enabled, and support Arduino connectivity while also providing ST Morpho extension headers that allow access to all of the microcontroller’s on-chip peripherals. As an mbed-enabled board, developers can make use of the mbed open source software platform, online tools and collaboration infrastructure at mbed.org. The board’s Arduino headers accept shields from the extensive Arduino ecosystem, allowing developers to add specialized functionality quickly and easily. ST will also offer its own dedicated shields supporting functions such as Bluetooth® LE or Wi-Fi® connectivity, GPS, audio recording leveraging the Company’s MEMS microphone expertise, proximity sensing, and wireless control.
Recent Entries »