Library 51- Chrom-ART Accelerator (DMA2D) graphic library on STM32F429-Discovery

Posted on January 27, 2015 at 11:05 PM

ST’s Chrom-ARTTM Accelerator function or DMA2D is supported in this library. This is powerful tool in STM32F429/39 or STM32F427/29 devices. It is based on DMA transmission from graphic to memory in top possible speed. This can be used to draw moving objects, rectangles, circles very fast without a lot of work.

My DMA2D GRAPHIC library was designed in a way that can support any LCD. Because anything that DMA2D knows is writing “data” (color) in memory at some locations. You still need some way to transmit data from memory to LCD. So library was designed that you can custom set start memory address, LCD width, LCD height and LCD orientation. Then the magic to writing in memory can start.

In case of STM32F429-Discovery, external SD-RAM is connected to MCU. In this case, SD-RAM has some logical address, in our case is 0xD0000000. DMA2D just knows that there is starting address and that LCD is 240px width and 320px height. When you want rectangle on x = 10, y = 10 location, library will calculate memory location where to transmit data for you.

Also, you need separate driver to transmit your data from memory to LCD. In case of STM32F429-Discovery board, LTDC periperal is in use. Again, LTDC peripheral knows start address of LCD memory (0xD0000000) and it can start work.

These 2 settings (LCD width, LCD height, memory start address) are by default set for STM32F429-Discovery compatibility, but you can set it to your needs any time. More below.

Library

Features

  • LCD independent
  • LCD orientation supported
  • Easy to port to another application with just 3 settings
  • Writing to memory with DMA2D fastest speed
  • Supported on STM32F429-Discovery board
  • Draw rectangles, lines, circles, triangles, rounded rectangles with fastest speed
  • Unlimited layers if they are supported by your peripheral to transmit data to LCD
    • In case of STM32F429-Discovery, LTDC can use 2 layers
    • Memory offset is used for new address

Continue reading

How to properly set clock speed for STM32F4xx devices

Posted on January 22, 2015 at 4:53 PM

I see that you have problems with your devices when you don’t know even (and you don’t even ask) on which speed your device is actually running. Speed of your device depends on PLL settings or clock source you have selected for system core clock.

In most cases system core clock’s source is PLL output. To get proper value, you check ALWAYS first these settings when something is not working. Because I’m tired of questions that something is not working but then your MCU clock is totally failed.

STM32F4xx series MCUs have ALL 16MHz RC oscillator inside which can be used for PLL input clock. It is not so accurate but it works just well if you don’t have connected external clock.

External clock is probably your crystal you have connected. In this example we will talk in case that you have external crystal connected.

If your clock is not properly set, then you have problems with everything. USB not working, USART baudrate failed, timer’s clock not OK…

To be able to get your MCU to full speed, you have to do the following changes:

  • In file stm32F4xx.h set HSE_VALUE to match your crystal frequency (In Hz)
    • In case of any STM32F4xx Discovery board, select HSE_VALUE = 8000000
    • In other case, you can set this to your crystal
    • If you have an option for global defines in your compiler, then add HSE_VALUE=8000000 to your defines.
    • If you don’t use external crystal or clock, then you don’t need to change anything
  • In file system_stm32f4xx.c set PLL_M value to match your crystal frequency (In MHz)
    • In case of any STM32F4xx Discovery board, select PLL_M = 8
    • This will divide input clock with 8 to get 1MHz on the input for PLL
    • If you don’t use external clock, then this value MUST be set to 16, because internal RC will be used for PLL
  • Now you can expect top speed for your device.

Continue reading

Library 50- STemWin for STM32F429-Discovery

Posted on January 12, 2015 at 10:33 PM

ST provides emWin library from Segger. It is professional GUI (Graphical User Interface), optimized for speed and performance for microcontrollers. ST has it’s own implementation, called STemWin. With this GUI, you can do many thing, of use simple buttons, dialogs, text boxes, to playing videos, displaying pictures, menus, etc. I suggest you that you go to segger’s website and read more about this very useful tool.

In my library, I’ve some changes from original ST’s example for STM32F429-Discovery board, because it has external ram (which is necessary for professional GUI) and LCD on board.

This library is just implementation (behind the scenes) to get emWin in working state on discovery board. How and what to do to use it is on you to take a look on emWin datasheet.

Library

Features

  • Use GUI on STM32F429-Discovery board
  • Compatibility with emWin professional GUI
  • External ram is used
  • 1 Layer
  • Screen rotation supported
  • Touch screen supported

Continue reading

Library 49- One-Time programmable (OTP) bytes on STM32F4

Posted on January 10, 2015 at 5:50 PM

STm32F4xx devices have OTP (One-Time-Programmable) bytes. They can be used for permanent store of configuration data for your device. Bytes are structured in 16 data blocks where each block has 32 data bytes of available memory.

There is also 17th block with 16 bytes of data. His “work” is to store information about states of data block, because you can lock each block forever even if it is totally empty.

Important notes:

  • When you write data to specific OTP location which is empty, and if you try to write data there again, you can expect broken data after write,
  • If you lock your block, you are unable to unblock it back and you are unable to write data to block even if it is completelly empty,
  • You don’t need to write entire block at a time!

Library

Features

  • Operate with OTP memory
  • Write data to specific block and byte
  • Read data from specific block and byte
  • Lock block permanently
  • Check if block is locked

Continue reading

Library 48- Measure PWM input signal with STM32F4

Posted on January 6, 2015 at 10:52 PM

First library in 2015 is here. With it, you will be able to measure PWM input signal from “other world”. STM32F4’s timers have capability to make an interrupt on edge, when signal is active on input pin for specific timer. This allows us, to measure signal in input. With a simple calculations, we can detect frequency of signal and duty cycle.

Of course, this is not veery accurate, but with 168MHz F407 device, using 32bit TIM2 (high resolution) I got pretty good results. Input PWM was set to random value 2545Hz with 23% duty cycle. Results from TIM2 were:

  • Frequency: 2545.13Hz
  • Duty cycle: 22.97%

Result’s quality depends on frequency you measure and also on timer’s performance (prescaler, max period value).

In library below, everything you have to set are:

  • Timer you will use for measuring signals
  • Timer’s IRQ for NVIC interrupt request
  • Create timer’s IRQ for interrupt handler
  • Call defined function in this handler
  • Call function to get results
  • More in example..

Library

Features

  • Measure PWM input signal on all available timers with input pin possibility
  • Measure frequency and duty cycle

Continue reading