ARM Programming Primer; Getting The USART Running

We find it interesting that PIC and AVR programming is very common in hobby electronics but ARM doesn’t have nearly the same foothold. This is partly because there’s a knowledge barrier involved with making the transition (the other part is probably the lack of DIP packaged chips). But if you’ve worked with 8-bit microcontrollers you can certainly make the jump into the 32-bit realm. Here’s a great opportunity to get your feet wet. This guide will show you how to get the USART on an STM32 Discovery Board working, which makes it easy to get feedback about what’s going on in your program.

One difference you’ll notice when moving to ARM microcontrollers is that there is almost always a library bundle available from the manufacturer which includes all of the functions you need for hardware control (USART, USB, Ethernet, ADC, etc.). That’s the case here, so simply including the USART library makes it a snap to finish the rest of the program. Once you hook up your communications hardware (an FTDI cable in this case) just use the library initialization functions, followed by the send and receive commands and you’ll be pushing messages to a computer terminal in no time.

If you’re trying to use the STM32 Discovery Board with a Linux box here’s a shove in the right direction.

13 thoughts on “ARM Programming Primer; Getting The USART Running

  1. I have recently started programming for an ARM Cortex-M3 (LPC1768). It is great to have the added processing power and peripherals, no more time spent wondering if it’s possible to cram that extra function in. Yesterday i finally managed to get it to send stack traces to a PC when it crashes, really helps debugging. I could buy a real debugger but that requires money, and i lack money =(.

  2. I have an LPC Xpresso and would like to get started with it.I’m not able to find any tutorials to help me decode the wierd code examples,or using the un-documented “drivers” …Any pointers?

    1. yes i am on the same track (lpcxpresso) and stuck too. I found it quite not so easy to figure out what libraries exist, what they cost, and if you can use them for GPL stuff. The Forum for me has not done the trick yet.
      But, within 2h, I have managed to get the dev-environment working, and managed to flash some example on it. But I in the next hour failed to togggle a pin.
      For me, this experience made it very obvious, what arduino is doing right.
      But on the other hand, speed is required. And I guess its just lack of time spent in the learning curve that made stuck for now.

  3. I have been using STM32 under Linux for a year now, and everything is working great, including debugging. Btw, there is already a lot of people hanging around on ##stm32 in Freenode.

    Personally, I have found that the ST peripheral library is useless crap. I tend to rather address the hardware directly, or use chibios, which provides some very cool abstraction:
    http://www.chibios.org/dokuwiki/doku.php

    1. I don’t like the CMSIS libraries also as I find them to be a lot of writing for simple things that could be done by writing into 2 or 3 registers.

      On another hand, it seems useful to master CMSIS libraries as they supposed to be identical accross different chip brands

      1. In my opinion, microcontroller code at this level is never directly portable between different brands. There are always too many variables, such as into which pin everything is connected and the different peripherals etc.

        A simple UART code may be portable when CMSIS acts as an abstraction layer, but for anything more complex you need to pay attention to the low-level details.

    2. Agree with jpa. The ST peripheral library is a bloated waste of space.
      I’m finding that I can shorten my learning curve by abandoning the crap they are offering and writing my own libraries.

      How can this situation be helpful to a student or new developer?

Leave a Reply to stefanCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.