Library 45- Interface backup SRAM on STM32F4

Posted on December 11, 2014 at 5:58 PM

Almost all (except STM32F401/STM32F411) STM32F4xx MCUs have internal backup SRAM, which stores data, if power is at least on Vbat, or main voltage is active.

These MCUs have internal 4-kBytes of SRAM. It is on location where if you read “too much” you can make a HardFault error and this is something you don’t want. So be careful when you are doing with this ram.

Backup SRAM can be also used as EEPROM, if your Vbat battery is always active, so you can store data which will stay there also if you reset your device. You just have to make sure that you don’t shut down your power supply.

Difference between backup SRAM and normal SRAM is that backup SRAM stays the same if main voltage is off (but Vbat is still active), but normal SRAM will loose data stored inside.

Important: If you will try working with backup SRAM on STM32F401 or STM32F411 devices, you will get “HardFault” error when you will try to read from backup SRAM register locations.

These devices don’t have backup SRAM inside so do not try to do that or your device can stuck.

Also, not available on any STM32F4 Nucleo board.

Library

Features

  • Interface 4-kBytes of backup SRAM
    • Does not work on STM32F401/411
  • Read/Write 8-bit value
  • Read/Write 16-bit value
  • Read/Write 32-bit value

Continue reading

Library 44- STM32F4 unique ID and flash size

Posted on December 10, 2014 at 9:41 AM

STM32F4xx devices have some parts in memory, which are read only and store some information about device. You can use them to protect your program if it is stolen from memory, or to tell programmer/debugger which device is connected with and detect flash size.

This library covers 4 things you can read from device:

  • Device signature
    • Device signature is something that you probably want to know when you are working with some device. This feature returns you 16-bit length device signature value.
  • Device revision
    • Some devices are from time to time updated in features, but with same name. This register returns you a revision in which it was made.
  • Flash size
    • Flash size is 16bit value stored somewhere in MCU. Value is in kB (kilo bytes)
  • Unique ID
    • 96-bit long identification part, where bits are factory programmed. Each device has different number, which gives you an opportunity to check if program on the device is “stolen” from another device, so you can disable functionality.

Library

Features

  • Read device signature
  • Read device revision
  • Read device’s flash size in kB (kilo bytes)
  • Read 96-bits unique ID in different read modes:
    • 8bit mode
    • 16bit mode
    • 32bit mode

Continue reading

Overclock STM32F4 device up to 250MHz

Posted on November 25, 2014 at 12:38 AM

Let’s test what STM32F4xx devices can do. I have all “4 speed families” at home so why not to try it how fast we can go. By default, for those who don’t know max frequencies for STM32F4xx devices, they are in list below:

  • 84MHz: STM32F401 MCUs, including Nucleo-F401 board
  • 100MHz: STM32F411 MCUs, including Nucleo F411 board
  • 168MHz: STM32F405/7 and STM32F415/17 MCUs, including STM32F4-Discovery board
  • 180MHz: STM32F427/29 and STM32F437/39 MCUs, including STM32F429-Discovery board

Ok, we have everything provided, let’s test how far we can go with PLL settings. First we have to go through, how to set PLL parameters to even get any clock. Step by step on how PLL works. Continue reading

Project 03- STM32F4xx PID controller

Posted on November 22, 2014 at 10:57 PM

CMSIS files from ARM provides ARM Math functions. There are also PID controller functions in different formats for f32, q31 and q7. This tutorial/project will talk about how to implement PID controller on STM32F4xx using PID functions from ARM.

PID Controller

Fast about PID controller. PID stands for Proportional-Integral-Derivative controller. This is a control loop feedback mechanism widely used in industrial control systems. It calculates the error between measured value and the desired setpoint value. According to the error, it then calculates output value to minimize this error.

PID Controller block diagram

PID Controller block diagram

Continue reading

Project 02- Snake game for STM32F429-Discovery board

Posted on November 16, 2014 at 1:08 PM

After first FFT project, I’ve decided to make a simple snake game. Basically I’ve made it in Labview first for my partial exam at the university. It looked great so why not port it also to STM32F429-Discovery board which has everything already prepared for us.

You just need USB OTG cable and external keyboard to drive snake and you are ready to play.

Snake game

Features

  • Works on STM32F429-Discovery board
  • Supports external keyboard using USB HID Host stack on STM32
  • Supports selecting different speeds
    • More speed, more points
  • Standard snake game mode
    • Your goal is to make snake larger as possible
  • Supports 2 game modes
    • Mode 0: If you hit wall, game is stopped
    • Mode 1: If you hit wall, snake will come out at the other side of game area
  • Supports pause mode

Continue reading