Category Archives: Prototyping boards

STM32F030F4P6 “AVR programmer” board

by Krzysztof Foltman

After the initial success with LPC810, I was ready to work on something with more memory and more I/O. Searching the Farnell catalogue for simple, low-cost and hobbyist-friendly MCUs, I found the tiny STM32F030F4P6 microcontroller made by ST Microelectronics.

The microcontroller

The chip is based on an ARM Cortex M0 core, has a 48 MHz clock, 16 KB ROM and 4 KB RAM and is available in a 20-pin 0.65mm TSSOP package.
Unlike the LPC chip, it provides plenty of I/O pins and a wider selection of peripherals, including SPI and timers. It is still an entry level chip. It has none of the advanced interfaces like USB or I2S present in its larger counterparts, but that gets reflected in price – it costs about 1.50 euro in single units.
The low price is particularly important for people without experience with soldering of relatively fine-pitch SMD packages – with some basic magnification they are not prohibitively difficult to solder, but getting a number of spares makes the whole learning process less stressful.

Several options are available to make sure that I would be able to use the new microcontroller. One of them involves using an SMD breakout board and a breadboard. However, I was skeptical of the ability to get the Serial Wire Debug programmer/debugger working with the breadboard – it usually requires fairly short wires and it is sensitive to signal quality issues. There is also the “dead bug” approach of gluing the IC upside down and soldering wires to it. This I rejected because of the soldering skills required. My easiest option involved using the first version of a 10x10cm matrix protoboard that arrived from China some time earlier.

Getting it working

After soldering the chip to the PCB, I needed a way to verify that it was working. The easiest way to achieve this was adding a decoupling capacitor and the SWD port, and using an STLink v2 programmer I got from Stijn to communicate with the chip. These programmers are easily available from eBay or Aliexpress, and work fine most of the time – the issues are usually resolved by holding the chip in reset manually. The example eBay link to get one of those programmers is Here

It took some trial-and-error to get adequate signal quality: long cables or having signal wires too close makes the communication unreliable at speeds that STLink is using. I found the correct configuration file to use with OpenOCD (32f0308discovery.cfg – it is included with OpenOCD).

Some time later, I had a working SWD set-up. On my system, and OpenOCD installed in /usr/local/, the example command to erase the flash and program an .elf file is:

sudo openocd -f /usr/local/share/openocd/scripts/board/32f0308discovery.cfg -c 'init' -c "program file.elf verify reset"

The next step involved writing a small program that blinks a LED, in order to make sure that the basics work. For this, I decided to use the code and the linker script for the LPC as a starting point. The memory addresses and the entire initialization code had to be changed to reflect the differences between platforms. And no more I2C or port expanders – this chip had enough I/O to do something that I could use in practice.

The project

At the time, I was trying to make a camera rail controller for a friend. It was meant to be a simple radio-operated stepper motor controller. That in itself could be a good opportunity to try a new microcontroller, if it wasn’t for the size constraints on the device. The 10x10cm prototyping board was too large to fit in the carriage of the device, and the smaller prototyping board was through-hole only. Also, the project didn’t really require a lot of processing power, an ATmega chip would work equally well.

A project based on ATmega is probably easiest to prototype using Arduino environment. But it’s not like it’s easy to buy an ATmega with bootloader burned in, at least in Ireland – it might involve a few days of waiting or paying a good chunk of money for an original Arduino from Maplin just to source the chip. So, what if I built a device to do exactly that – to take a blank ATmega and burn the Arduino bootloader into it. Sounds like a nice learning project to use the STM32 for!

The STM32 definitely had enough I/O pins and memory, and an SPI peripheral that could be used for communicating with the AVR In-Circuit Serial Programming port. The board had enough space to host a 28-pin ZIF socket, so I added that and some user interface elements – two LEDs (green and red) with suitable resistors and a reset button. The SPI-based ICSP code was easy enough to write based on Atmel’s documentation: IMG_20140911_224839 (1)the datasheet and the AVR910 application note about using the programming interfaces. Finding the correct version of the Arduino bootloader was slightly harder than I expected, but I had it all working after a single afternoon of coding. The slightly cleaned up version of the code and very rough documentation is available here

The remaining parts are:

  • the clock crystal and the load capacitors for the ATmega – but not for the STM32 as it runs off its own internal RC clock
  • the beeper – not strictly required but a nice addition. I didn’t dare to power the beeper directly from the microcontroller, so I used an 2N3904 transistor in common emitter mode as a switch.

The programmer code checks the device ID and uploads the bootloader, sets the correct fuses and then uploads a blinky example.

Now, any time I want to make a simple device based on an ATmega microcontrolller, I don’t need to buy a pre-programmed chip – I can get a blank one and pre-program it by simply inserting the chip into the board’s ZIF socket and press a button. After a while, I get a long “beep” and a green light, announcing the fact that the chip is functional and ready to use. Even better, this board provides a simple way to check an Atmega chip that I suspect to be damaged during one of my failed experiments: a series of beeps and a red light will remove any doubt.

Summary

This Is Not Rocket Science at all.

The tricky parts is soldering and SWD signal quality, and the initialization and the linker script. One needs to remember to enable all the clocks during start-up and to take care of the interrupts. Otherwise, there may be unexpected crashes when SysTick gets triggered and there is no ISR to call. Overall, this chip is easy to obtain (Farnell), inexpensive, relatively easy to use and less limited than the 8-pin LPC chip.

There are some comparable options from other manufacturers in the same market segment: LPC811 and LPC812 from NXP (the latter is also available in a 20-pin SOIC package with 1.27mm pin pitch, making it easier to solder). My preferred option was an STMicro part because of my prior experience with their Discovery boards and the fact that most of skills learned when working with a specific microcontroller are usable across their entire chip lines. Most of the time they use the same peripheral, so parts of the code can often be ported -with minimal changes- to their 180 MHz parts. NXP parts have several other advantages, the most important being the clear documentation they provide and their very flexible pin assignment matrix.

LPC810 board

by Krzysztof Foltman

This is my first successful attempt to do something with a 32-bit microprocessor in a circuit of my own making, instead of relying on commercially-available development boards. After some prior unsuccessful tries using STM32F051 and TQFP64 to DIP breakout boards, I decided to start over with something easier. Something that would not require SMD soldering skills, a custom board or any special tools. With all those requirements, I picked the only 32-bit microprocessor that is easily available in a hobbyist-friendly package: the NXP LPC810.

The microcontroller

This chip is an ARM Cortex M0+ core. The basic specs are rather modest:

  • up to 30 MHz clock (built in, no crystal or external oscillator required)
  • only 4KB of flash,
  • 1 KB of SRAM,
  • 6 pins of I/O.

It’s available in an 8-pin DIP package, which every electronics hobbyist should be familiar with – the same package is shared by many popular chips, operational amplifiers, headphone amplifiers, switching-mode power supply controllers and many others. It can even be used with a breadboard. Can’t get any easier!

The datasheet and the user manual, as well as some application notes and errata sheets are available at: See here

Programming the chip

For programming I used a simple USB-to-TTL-serial dongle – no special hardware is required to flash the device. Well… not all that special. The programming mode is activated by holding the PIO0_1 pin down during reset. In order to keep the ability to use that pin for other purposes during normal operation, I used a 2N3904 transistor to pull it down on the RTS signal from the serial dongle. So, depending on the state of the RTS line, pulsing DTR low would either run my program or enable program upload mode. The RTS and DTR can be controlled from the PC in software, so all the required modes – normal operation, normal reset and reset to programming mode – can be triggered. As an alternative, LPC810 also supports the Serial Wire Debug mode, which I haven’t tried yet with this particular chip.

The programming protocol is well documented and there is an existing example of using LPC810 with open tools, including a short programmer program and the linker script: See here

I/O expansion

The limited amount of I/O may be insufficient for any complex designs. Out of 8 pins, two pins are used for power, and three more have to be sacrificed for programming interface and the reset. So, in the end, only 3 GPIO pins are left. Even with the unusual ability to freely reassign some functions to any of the pins, there’s not much that can be done using so few pins.

One of the solutions involves adding a port expander, which I did. I decided to use Microchip’s MCP32008, an 8-bit expander using an I2C bus. This way, 2 data pins are used to provide up to 8 pins of general-purpose I/O, and the direction can be set for individual pins. If that’s not sufficient, more expanders can share the same bus. It is also possible to use MCP32016 – a 16-bit expander – for even more I/O on a single bus address. There are few more alternatives from other manufacturers, too: NXP’s PCF8574 is another popular choice.

In order to build the test device, I used one of the 5x5cm This Is Not Rocket Science matrix protoboards, which provide just enough space to fit the LPC810 and the MCP32008. It requires a bit of careful planning to fit all the components, but no special skills are required.

The hardest part of adding an I2C port expander was the electrical interface: open drain outputs with appropriate pull-ups for the bus. For clock it is possible to use the built in pull-up, but for data I had to add an external resistor. The software – both initialization part and the actual I2C transactions – is not particularly complicated. The documentation contains very detailed, step-by-step instructions to get each peripheral working, and related registers are often cross-references in the right places. This is very different from my experiences with STM32 series chips, where critical information is scattered between the reference manual, data sheet and possibly application notes and other documents. In STM32’s defense, those chips are also much more complex and powerful than LPC810, so a comparable level of detail would make the reference manual run into many more thousands of pages.

Verdict

Overall, using both the LPC810 and the port expander is Not Rocket Science at all. Soldering is easy because of the DIP package, and it’s possible to use a socket to further reduce any thermal risks. The programming interface is a simple serial port + 2 control pins. Both chips are easy to get and inexpensive and documentation (link above) is clear, detailed and helpful.

This is as stress-free as it gets for building the first circuit based on an ARM Cortex M chip.

However, due to small memory, lack of DMA or analog inputs and very little I/O, the chip is of limited use.  It would probably do decent enough job for things like controlling relays or a character LCD from USB, at least when combined with a USB-to-serial dongle – but if I only needed that, in most cases a better choice would be an 8-bit AVR chip in an 8-pin package, like ATtiny85.
However, if I had to use a 32-bit microcontroller for such a task, I would probably pick this one.

The yellow panel – prototyping utilities.

The recent DirtyPCBs.com paneling experiment resulted in a nice new addition to our prototyping toolbox:

the yellow panel.

And the yellow panel..  Dirty dirty DIRTY soldermask (check topleft)And the other side.

The yellow panel contains:

  • Wolfsom SMT microphone breakout with small amplifier
  • QFN24-to-dip adapter
  • Freescale K20 TFT backpack (enhanced Teensy3.1 without the bootloaderchip)
  • Freescale KL02Z DIP breakout with microphone
  • USB-testpoint board in USBstick form
  • 0.49″ I2C OLED breakout board
  • 3.3v MIDI IO board
  • KL02Z micro-gameboy with 0.49″ OLED, microphone, switches and battery.
  • A this-is-not-rocketscience.nl keychain

The general theme for this board is “controlling stuff with audio while having sufficient visual feedback” I will be soldering a few of these over the next few weeks to test out various ways to get light/motion things synced up to music.

The microgameboy (screens have not arrived yet – they will get their own post once the hardware is complete):

IMG_1566 IMG_1565

Code upload works! Blinky fizzbuzz LEDs!

IMG_1567

USB testpoint thing soldered in 2 configurations:

IMG_1564 IMG_1563

If you’d like to try these as well – get some at DirtyPCBs.com and ask us for schematics/bom/help on twitter!

New PCB order – small DIP protoboards

Krzysztof Foltman writes: “Another PCB sent to manufacturing. This time, it’s a universal 5x5cm protoboard. If you’re a beginner at electronics and want to try making a simple electronic circuit using standard through-the-hole components, it’s probably going to save you a lot of time. It’s compatible with DIL chips but also supports double-row pin headers quite nicely – something I missed in the cheap protoboards from ebay!”

fsm 5x5 protoboard

Download GERBER files.

Progress on new protoboards

After using our V1 prototyping boards for a while we decided to design some improved versions to make future experiments easier.

This new board is focussed on mostly analog setups:

Protoboard-Analog-V1
It features a switchable supply between USB and external power and an area for SOIC MCU’s and CODECs.

This board is an upgrade from the v1 protoboard:

Protoboard-Goldfish-V1

– The connector placement has been improved.
– There is a new hole pattern and connector which makes it fit the Goldfish platform (giving instant access to graphical user interfaces to control experiments – or an FPGA daughterboard with HDMI for heavy lifting)
– There is dedicated space for an Atmel Attiny85 beside the TQFP area which can give a quick and dirty USB interface to whatever TQFP is on the protoboard. (using the VUSB library). It can also be used to generate reference signals or bootloader portknocking.

As soon as the new Goldfish mainboard + extension header has been finalized we will add these protoboards to the next batch to be sent to the PCB factory.