Library 23- Read RFID tag with MF RC522 on STM32F4xx devices

Posted on July 13, 2014 at 5:58 PM

In this library I’m talking about RFID (Radio-Frequency IDentification).

Radio-frequency identification (RFID) is the wireless non-contact use of radio-frequency electromagnetic fields to transfer data, for the purposes of automatically identifying and tracking tags attached to objects. The tags contain electronically stored information. Some tags are powered by and read at short ranges (a few meters) via magnetic fields (electromagnetic induction). Others use a local power source such as a battery, or else have no battery but collect energy from the interrogating EM field, and then act as a passive transponder to emit microwaves or UHFradio waves (i.e., electromagnetic radiation at high frequencies). Battery powered tags may operate at hundreds of meters. Unlike a barcode, the tag does not necessarily need to be within line of sight of the reader, and may be embedded in the tracked object.

source: For that I used Mifare RC522 RFID reader from NXP. I got it on Ebay almost for free with 2 RFID cards included. This chip works with RFID on 13.56MHz. To get this to work, you also need RFID cards with same working frequency (included in packet from ebay). I got this working on STM32F429 Discovery board with SPI communication and display data on LCD on board. Detection distance was about 10cm from receiver.



  • Read RFID card at 13.56MHz
  • Working with SPI

Continue reading

Library 22- True random number generator for STM32F4xx

Posted on July 10, 2014 at 6:19 PM

STM32F4 devices (in most cases) have True Random Number Generator (or RNG). This peripheral can provide 32bit random number. I made a small library, that you can enable and use it very quickly.

RNG Library


  • True random number generator
  • Support 32bit numbers

Continue reading

Library 21- Read SD card with FatFs on STM32F4xx devices

Posted on July 10, 2014 at 4:26 PM

Finally I got it working properly. Reading SDcard was very awesome for me for first time, so I decided to make a library for STM32F4xx devices and post it to my website. It’s basically just communication interface between STM32F4xx and FatFS library by Chan.

FatFS Library


  • Fatfs by Chan supported, version R0.10b
  • Support for SDIO or SPI interface
    • SDIO works with 1- or 4-bit mode
  • Support for Card detect pin
    • Can be disabled
  • Support for Write protect pin
    • Can be disabled
  • Custom fat time
    • Enables you to implement your own time using RTC

Continue reading

Library 20- Independent watchdog timer on STM32F4xx

Posted on July 9, 2014 at 11:22 PM

Sometimes you need watchdog timer to look at your system if it gets stuck. I made a little library to work with it.

Watchdog in STM32F4xx device has it’s own clock which is independent from main system clock. You have to constantly reset it’s counter value or it will elapse and reset MCU.

Watchdog Library


  • Detect if system was reset by watchdog
  • Supports different timeouts
  • Reset watchdog

Continue reading

Library 19- Use internal RTC on STM32F4xx devices

Posted on July 9, 2014 at 10:00 PM

It’s been some time when I post last library. Next one is internal RTC library. STM32F4xx devices have Real Time clock inside, with support of internal calibrated 32768 Hz oscillator or external (more accurate) 32768 Hz oscillator.

RTC peripheral has also backup register support, which means that when you reset MCU, registers are not reset or if power is off and you have battery connected on Vbat pin, clock is still working.

RTC can also wakeup MCU from all powerdown modes.

Library also provide converting time to epoch time (seconds from 01.01.1970 00:00:00) and back.

RTC Library


  • Support Internal or external clock source
    • PC14 and PC15 pins are used for external crystal oscillator
    • STM32F4/24 Discovery does not have RTC crystal onboard. Check board’s manual on how to set it up
  • Support wakeup interrupt
  • Get seconds from 01.01.1970 00:00:00
  • Get readable time from seconds from 01.01.1970 00:00:00
  • Support to save/get data in binary or BCD format

Continue reading