The Woes of Debugging DMA on the STM32 Platform

I spent a good chunk of today getting frustrated with my AVC code. I have custom firmware on my GPS so that it sends a fixed-length binary sentence to my microcontroller. Rather than polling the USART, or handing an interrupt every time a character comes in, I figured this is a perfect application for the DMA controller... tell the DMA controller how many characters there are, and have it wake up my code when I receive a full GPS sentence.

Well, during debugging, I found that my DMA IRQ was being handled once, but I couldn't get it to trigger a second time. After wrestling with this for hours, I finally thought, what if the second DMA interrupt really is happening, but because I've got the CPU stopped at a breakpoint, I'm missing it?

So, I took out my breakpoint and instead threw a character out the USART every time the DMA IRA was called. And lo and behold, I got a DMA IRQ five times a second, which is just how often the GPS is sending me data.

Embedded programming can be so frustrating.

Using the FAT filesystem on SD cards with the STM32F4 Processor: Part I

The other night I was able to get my STM32F4DISCOVERY board to read and write files on an SD card formatted with the FAT filesystem. While I haven't done extensive testing of my code, I'm comfortable enough to share what I have with the world. Writing to a filesystem is obviously a convenient feature in many projects. Here's how you can do it with an STM32F4 processor. What follows is the long story; you can find my code at the end of the post. Continue reading Using the FAT filesystem on SD cards with the STM32F4 Processor: Part I

Sparkfun AVC Thoughts

Sparkfun has recently announced that the 2014 Autonomous Vehicle Contest (AVC) will be held on June 21, 2014.

The AVC, as its name implies, is a contest where contestants build vehicles that must navigate a course autonomously. That is, no input or guidance from a driver or pilot. I've been following the AVC for a couple of years now and have thought about entering before. This year I think I just might do it. The STM32F4DISCOVERY board appears to be a perfect platform to build upon for the contest. That board, a few sensors and a whole lot of code sounds like just the ticket.

There are two categories of competition: ground and air. I'm not yet ready to build a self-piloting drone. But a self-driving model car is probably a good stretch goal for me to build on my embedded skills. I've already starting writing a code library to write debug output to a serial port. I'm planning on picking up a BlueFruit bluetooth link from Adafruit to stream the debug spew back to my laptop. The F4 also features an embedded USB host port, so I'll write debugging info to a file on a USB thumb drive as well. With a high clock speed (180MHz), lots of Flash ROM (1MB) and RAM (192K), and plenty of I/O, it should be a generous platform on which to build.

I guess I should revisit my series on setting up a FOSS cross compiler toolchain and figure out how to configure it for the STM32F4 series.

Free STM32F4DISCOVERY dev board

ST Micro just announced the STM32F4 series of processors and the STM32F4DISCOVERY kit. In fact, as I write this, ST is having a giveaway promo for the new discovery board. I have been thinking of an audio effects processor project for which this series of chips would be perfect. They have floating point processors, I2S interfaces, external memory interfaces, and high clock rates. (Yes, this is the same project idea I had for the Renesas RX600 contest. The two chips both have features that make them candidates for the project; I'll discuss the pros and cons of each in a later post.)

So, of course, I ordered one right away. (Especially when I found out it was free!) It was shipped remarkably quickly. Digi-Key is clearly the fulfillment house for ST based on the return address on the package. The board comes in clamshell packaging with little to no documentation.

I have 2 or 3 projects in my queue right now (and still have a wife, a job, and two kids) so it may be a while before I get to use this.