Posts belonging to Category Microcontroller



Review: STM32 F3-series Discovery Kit

STM’s STM32 F3 series of microcontrollers offer 32-bit performance with DSP functionality. To make the evaluation of this microcontroller easier, STMicroelectronics offers an evaluation board called the STM32F3DISCOVERY.

If you have ever wanted to experiment with an RISC microcontroller that comes with special Digital Signal Processing (DSP) capability, the STM32F3DISCOVERY board might just be the right board for you to start with. STMicroelectronics shipped out a board to me for review. Let’s have a look!

The STM32 F3 series of microcontrollers are based on the 32-bit ARM Cortex-M4 core, which has Digital Signal Processor (DSP) extensions and a Floating-Point Unit (FPU). The STM32F3DISCOVERY board comes with an STM32F303VCT6 [1] microcontroller featuring 256 KB Flash, 48 KB RAM in an LQFP100 package [2].

  • STM32F303VCT6, ST’s ARM® Cortex™-M4F based MCU with:
    • 256 KB Flash
    • 48 KB SRAM
    • Maximum CPU Frequency: 72 MHz
    • Real Time Clock (RTC)
    • 2 x Watchdog
    • 9 x 16-bit Timer
    • 1 x 32-bit Timer
    • 4 x 12-bit ADC (39 channels)
    • 2 x 12-bit DAC
    • 88 GPIOs
    • 3 x SPI
    • 2 x I2C
    • 5 x USART
    • USB
    • CAN
    • Supply Voltage: 2 – 3.6 V
  • L3GD20, ST MEMS motion sensor, 3-axis digital output gyroscope
  • LSM303DLHC, ST MEMS system-in-package featuring a 3D digital linear acceleration
    sensor and a 3D digital magnetic sensor.
  • Flexible power supply options
    • Power from either on-board USB connector
    • External 3 V or 5 V supply
  • On-board ST-LINK/V2
  • Reset button
  • One user push-button and 8 user LEDs
  • 100 mil (2.54 mm) expansion headers

Due to the kind of sensors the board offers and the DSP functionality of the MCU, the board is perfect for navigational experiments. The board offers plenty of horsepower to be used in autonomous Unmanned Aerial Vehicles (UAVs) such as Quadcopters and RC planes.

The board looks very organized and cleanly routed. There are two USB-port. One for the user application and one for the ST-LINK/V2 debugger. ST did leave an unpopulated spot for an external crystal for applications which require greater accuracy / precision.

STM32 F3 Discovery Board, top view

STM32 F3 Discovery Board, top view

What I particularly like is the 100 mil / 2.54 mm header on the bottom of the board. This header makes it easy to use breadboard style setups for experiments.

STM32 F3 Discovery Board, bottom view

STM32 F3 Discovery Board, bottom view

The default firmware features 3 small sample applications. On power-up, the 8 user LEDs will start lighting in a circular motion. If the user button is pressed, the LEDs will now indicate the direction of acceleration. If the button is pressed again, the 8 LEDs will act as a compass and indicate the direction to magnetic north.

Here’s a short video of the first demo application. Sorry for the poor video quality.

The board is available for $10.88 from Newark [3].

Links and Sources:

[1] ST 32 F302-series MCUs, STM: http://www.st.com/

[2] STM32F3DISCOVERY User Manual, STM: http://www.st.com/

[3] STM32F3DISCOVERY User Manual, STM: http://www.newark.com/

Review: Freescale FRDM-KL25Z development platform for Kinetis L-Series MCUs

Freescale’s new low-cost development platform FRDM-KL25Z featuring Freescale Semiconductor’s ARM® Cortex™-M0+ processor-based high performance, low-power Kinetis L series 32-bit MCUs has launched last Tuesday. Let’s check it out.

The FRDM-KL25Z “Freedom” development platform is an extremely inexpensive development board with a Kinetis KL2 Family 32-bit ARM®CortexTM-M0+ MCU [1]. The Kinetis L-Series MCUs promise true 32-bit performance at the price and power consumption of an 8- or 16-bit MCU.

Freescale and I tried to travel in time and present this review before the official launch last Tuesday. However, it turns out that the snail mail is not yet compatible with time travel. But the board is finally here, so let’s do it!

My Freescale FRDM-KL25Z Freedom Development Platform pre-production review sample has arrived

My Freescale FRDM-KL25Z Freedom Development Platform pre-production review sample has arrived

Please note that I am using a pre-production board for this review and the actual production board may slightly differ from this one.

Overview and Tech Specs

Before we jump right into the review, let’s have a look at the key features of the Freedom (FRDM-KL25Z) development kit. The board comes with a KL25Z128VLK4 MCU. The KL25Z128VLK4 is a Kinetis KL2 Family 32-bit ARM®CortexTM-M0+ MCU with quite a bit horsepower for such a small board. Here are the tech specs for the development board:

  • KL25Z128VLK4, Freescale’s ARM Cortex-M0+ based Kinetis L-Series MCU with:
    • 128 KB Flash
    • 16 KB SRAM
    • 64 B Cache
    • Maximum CPU Frequency: 48 MHz
    • Real Time Clock (RTC)
    • Watchdog
    • 4 Channel DMA
    • 12-bit DAC
    • Analog Comparator (6 inputs)
    • USB full-speed controller
    • Low Power UART
    • 2 x UART
    • Capacitive Touch Sensor (16 Channels)
    • 66 GPIOs
    • 23 GPIOs with Interrupt
  • OpenSDA–sophisticated USB debug interface
  • Tri-color LED
  • Capacitive touch “slider”
  • Freescale MMA8451Q accelerometer
  • Flexible power supply options
    • Power from either on-board USB connector
    • Coin cell battery holder (optional population option)
    • 5V-9V Vin from optional IO header
    • 5V provided to optional IO header
    • 3.3V to or from optional IO header
  • Reset button
  • Expansion IO form factor accepts peripherals designed for Arduino™-compatible hardware

The FRDM-KL25Z evaluation board can be pre-ordered from Newark and is advertised for an incredibly low price of just $12.95 [2]. The microcontroller itself is available for $ 3.85 [3]per piece from the same distributor. I personally hope that Expansion IO for Arduino™-compatible hardware will convince some Arduino / AVR-fans that the jump to a 32-bit ARM architecture is not at all out of their league.

Unboxing

My board came in a pre-production packaging and is therefore not representative for the production units. However, here are a few pictures:

My pre-production Freescale FRDM-KL25Z Freedom Development Platform featuring the ARM Cortex-M0+ based Kinetis L-Series MCU KL25Z128VLK4 has arrived.

My pre-production Freescale FRDM-KL25Z Freedom Development Platform featuring the ARM Cortex-M0+ based Kinetis L-Series MCU KL25Z128VLK4 has arrived.

Trying it on for size: Freescale FRDM-KL25Z Freedom Development Platform

Trying it on for size: Freescale FRDM-KL25Z Freedom Development Platform

The board is really compact. A little bit larger than a credit card, maybe. On the left side are the two USB Mini-B type connectors. The top one is connected to the MCU and the bottom one is used to flash the MCU and for the OpenSDA, a sophisticated USB debug interface. The expansion header seen here on the top and the bottom of the picture is not installed on the currently shipping development boards.

Bottom view of the Freedom FRDM-KL25Z

Bottom view of the Freedom FRDM-KL25Z

Just like the expansion IO header, the CR2032 battery holder in the top right corner is not installed in the KL25Z version currently shipped by the distributors. I heard several people complain about this but I only partially agree. If you really need the battery holder and the IO header, go ahead and order the parts together with the board from your manufacturer. You will have to solder them in yourself but it should only take a minute.

Software Installation

Before we can connect our hardware, we need to download and install the >Windows USB Driver OpenSDA Support< from P&E Micro Systems v11_120720 or later. The software is available for free and without an annoying registration form [4].

Windows USB Driver OpenSDA Support Dialog

Windows USB Driver OpenSDA Support Dialog

Next, there’s a bunch of files on the element 14 server that will be needed sooner or later. I recommend downloading all the files and extracting them to a known location. The files are available from [5] after registration and log-in.

FRDM-KL25Z (freedom) related Downloads from the element 14 page

FRDM-KL25Z (freedom) related Downloads from the element 14 page

The >WINDOWS DEVICE DRIVERS.zip (1.7 MB)< contains the Windows drivers that Windows might ask for when the board is connected to the PC for the first time.

When the board is connected to the PC for the first time (2nd USB connector, bottom left), the “Windows Driver Installation” dialog will pop up and attempt to install 4 devices. A USB Composite Device, a USB Mass Storage Device and a Freescale MSD USB Device (which should all install automatically) and an OpenSDA – CDC Serial Port (requires driver). The installation of the OpenSDA – CDC Serial Port will require a driver from the >WINDOWS DEVICE DRIVERS.zip (1.7 MB)< file. Just tell Windows the location of the extracted files and let the PC pick the right file(s). The driver for the OpenSDA – CDC Serial Port is also available on the board itself.

The Driver Software Installation dialog that pops up when the development board is connected to the PC for the first time

The Driver Software Installation dialog that pops up when the development board is connected to the PC for the first time

Programming the Microcontroller

The Freescale FRDM-KL25Z development board comes pre-programmed with a very nifty OpenSDA MSD Flash Programmer application. This piece of software is simply awesome. When the board is being connected to the PC using the OpenSDA USB port, the device will act like an external USB drive. The drive will identify itself as “FRDM-KL25Z”.

The mass storage device flash programming interface identifies itself as FRDM-KL25Z thumb drive

The mass storage device flash programming interface identifies itself as FRDM-KL25Z thumb drive

In order to transfer a program to the MCU, all one needs to do is copy the corresponding S-record file (.s19 or .srec) “FRDM-KL25Z” drive. That is all! No special software, no hidden secrets, nothing.

Thanks to the The mass storage device flash programming interface, flashing the FRDM-KL25Z is as simple as copying a file to a thumb drive.

Thanks to the the mass storage device flash programming interface, flashing the FRDM-KL25Z is as simple as copying a file to a thumb drive.

Example Programs

The files mentioned in the software section contain numerous different demo programs. To try them, simply copy the .srec file of the demo program onto the FRDM-KL25Z board as described above.

Here’s a short YouTube clip I shot using the demo programs >changy_rgb.srec< and >accellero_i2c_rgb.srec<:

Links and Sources:
[1] Kinetis KL2 Family, Freescale http://www.freescale.com/

[2] FRDM-KL25Z – EVAL BRD, Newark http://www.newark.com/

[3] MKL25Z128VLK4 MCU, Newark http://www.newark.com/

[4] OpenSDA Support, P&E Micro Systems http://www.pemicro.com/

[5] Element 14 Freedom Community http://www.element14.com

Freescale’s Kinetis L-Series ARM® Cortex™-M0+ based MCUs

Freescale announced a new line of ARM® Cortex™-M0+ based microcontrollers, the Kinetis L Series. The MCUs are supposed to offer the performance of a real 32-bit MCU at the price and energy rating of an 8-bit microcontroller.

A tight budget and low power requirements used to limit design engineers to 8-bit and 16-bit MCUs. Freescale’s new Kinetis L Series is supposed to change this and offer full performance, peripheral sets, enablement and scalability of a real 32-bit MCU with an exceptional energy efficiency and a low price.

All Kinetis L-Series MCUs are based on the ARM® Cortex™-M0+ core. All family members have several nifty features such as 12-bit ADC, SPI, I2C, RTC and even a touch sense interface in common. There are 5 sub-families of the Kinetis L-Series family for various different requirements [1].

The KL0 sub-family contains entry level MCUs with up to 32 KB Flash and 4 KB SRAM. Up to 256 KB Flash and 32 KB SRAM are offered by Freescale’s Kinetis KL1 sub-family. KL2 sub-family members offer the same features as the KL1 family plus an USB On-The-Go interface. Segment LCD MCUs are offered in the KL4 (without USB On-The-Go) and KL5 sub-family (with USB On-The-Go).

What makes this board interesting for homebrew designs is that Freescale offers a low-cost development platform equipped with a Kinetis KL2-series KL25Z128VLK4 MCU and a Expansion IO for Arduino™-compatible hardware. The FRDM-KL25Z development board, called Freedom, is available for just $12.95 from Newark [2]. The board is intentionally kept simple and offers an RGB-LED, an accelerometer and a capacitive touch slider as I/O-devices. The product is expected to start shipping next week. Until then, Newark takes pre-orders.

Freescale is going to ship out a pre-production Freedom FRDM-KL25Z development board before the official production boards leave their house and enable me to post a thorough an exclusive review before anyone else. So stay tuned for a “tell it like it is” guaranteed marketing BS-free review.

Links and Sources:
[1] Kinetis L Series MCUs, Freescale http://www.freescale.com
[2] FRDM-KL25Z development board, Newark http://www.newark.com

Microcontroller Controlled Police Strobe Light

Circuits with flashing LEDs and amazing color combinations are pretty popular. This is probably because they are not only simple but one can literally see the results instantly. Let’s have a look at a microcontroller controlled police strobe light using an ATtiny45 from Atmel.

LED flashing circuits have been around for ages and probably always will be. They are usually simple to build and they are fun to look at. Since my daughter has developed an interest in my electronic lab and particularly loves my boxes full of LEDs, I decided to build a little police strobe light for her.

ATtiny45 based police strobe light circuit

ATtiny45 based police strobe light circuit

The circuit is very simple, two LEDs, 3 resistors and the microcontroller, that’s it. The Attiny45 has enough drive current (max. 40 mA) to drive even ultra bright LEDs directly [1]. R1 is a pull-up resistor for the RESET pin (Pin 1) od the ATtiny45. Resistors 2 and 3 are current limiting resistors and need to be calculated based on the LEDs used. They will usually range between 100 and 220 Ohms.

To calculate a matching current limiting resistor for a LED, simply subtract the forward voltage (VF) from the supply voltage of the circuit (4.8 V) and divide the result by the LEDs forward current (IF).

R = (Vdd – VF) / IF

I wrote the program for the microcontroller in Bascom AVR. The source code is extremely simple and self-explanatory. In case you do have any questions regarding the program, just drop me a few lines using the comment option below. An Archive containing the .bas source file for Bascom AVR and a compiled .hex file for other programmers can be downloaded here.

‘ Atmel ATtiny45
$regfile = "attiny45.dat"

‘ Fuse-bits 8 MHz int. div. by 8
$prog &HFF , &H42 , &HDF , &HFF

‘ 1 MHz internal clock
$crystal = 1000000

‘ PortB is Output
Config Portb = Output

‘ Start flashing
Do

   Portb.= 1
   Waitms 150
   Portb.= 0
   Waitms 100
   Portb.= 1
   Waitms 150
   Portb.= 0
   Waitms 150

   Portb.= 1
   Waitms 150
   Portb.= 0
   Waitms 100
   Portb.= 1
   Waitms 150
   Portb.= 0
   Waitms 150

Loop

This is what the circuit looks like assembled on a breadboard. The Atmel AVRISP mkII programmer is still attached to it but is not necessary to operate the circuit.

Police strobe light prototype on breadboard

Police strobe light prototype on breadboard

And here’s a short Youtube video showing the flash pattern of the police strobe light:

Links and Sources:

[1] Atmel corporation, ATtiny25/45/85 Datasheet: http://www.atmel.com/

Resuscitate Atmel AVR from CKSEL Fuse-Bit Death

The most common way to ‘kill’ a Atmel AVR microcontroller is by programming fuse bits wrong. Sooner or later every Atmel AVR enthusiast will stumble across a fuse-bit related problem. The most common mistake, a wrong clock source selection through the CKSEL fuse-bit, can be fixed easily.

The fuse-bits CKSEL0 through CKSEL3 let the microcontroller know what clock source to use. Most Atmel AVRs have an internal 1 MHz RC-oscillator (or 8 MHz oscillator with divide by 8 prescaler) selected as factory default. The internal oscillator is completely adequate for circuits which don’t require precise timing. Therefore, many circuits do not implement an external clock source.

If one accidentally changes the CKSEL fuse-bits so that the controller is looking for an external clock signal, the microcontroller will appear brain-dead. To make it worse, the controller will no longer respond to programming attempts. This can be very confusing and time-consuming to troubleshoot if one faces this problem for the first time.

But the fix is extremely simple: Your microcontroller is looking for an external clock signal, give the controller what it wants, an external clock signal.

Locate the XTAL1 / CLKI Pin on your microcontroller and connect an external clock source. The frequency doesn’t really matter all too much and the drive level should be around TTL level. Once the external clock signal is attached to the microcontroller, one can use one’s standard ISP-Programmer to program the fuses back to normal.

Simple LED flasher circuit with ATtiny45

Simple LED flasher circuit with ATtiny45

Atmel AVRISP mkII and BASCOM AVR

More and more computers (especially laptops) aren’t equipped with serial and / or parallel ports anymore. Therefore, more and more programming interfaces utilize USB instead. However, some people are extremely attached to their older serial / parallel programmers and often oversee how a USB based device can simplify their life a lot.

Atmels’s AVRISP mkII doesn’t just work with AVR studio; Other proprietary software, such as AVRdude and Bascom AVR work together with the mkII just fine. This short article is showing how to make the mkII work with Bascom AVR.

Bascom AVR [1] AVR is a Basic compiler for the AVR microcontroller family. Atmel’s AVRISP mkII is an In System Prgogrammer (ISP) intended to be used with AVR studio. At first Bascom didn’t support the mkII directly. But that has changed and Bascom now supports the AVRISP mkII natively.

The first step to set the mkII and Bascom up is of course to install the AVISP mkII’s drivers. I highly recommend the modified drivers [2], which are specifically designed to support third party software.

The next step is just as easy. Start up Bascom and select Options -> Programmer. Under ‘Programmer’ select ‘USBprog Programmer / AVR ISP mkII’ and click ok. That’s all there is to it!

Bascom programmer options menu

Bascom programmer options menu

Please note that it is no longer necessary to use AVR studio to program an AVR microcontroller if you use Bascom. There are many how-to’s and tutorials out there which show how to use AVR studio solely for the programming part with Bascom. They are outdated and no longer recommended.

Links and Sources:

[1] MCS Electronics, Bascom AVR Download: http://www.mcselec.com

[2] MightyOhm, AVRISP mkII libusb drivers: http://mightyohm.com/