Library 58- Dynamic strings on STM32F4xx

Have you ever been in position where you need to store some string informations just for a small amount of time? Did you reserve ram memory before you worked with strings?

If you did it like that, than this library might be a solution for you.

This library was designed directly for a purpose where you need to store your information for a few time. For example, getting some string informations from your sensor, USART, etc.

It uses malloc and free functions to allocate a memory inside HEAP section of RAM. So, if you have in plain to use a biiig array of strings, first make sure that your HEAP section is big enough where malloc and free functions can operate.

Library

Features

  • Dynamic string operation
  • Allocation size depends on string size only, no preallocations
  • Allows for dynamically search for new sections of memory if current preallocated memory is full
  • String deletion allowed one by one or all at a time

Dependencies

  • CMSIS
    • STM32F4xx
  • TM
    • defines.h
  • C
    • string.h
    • stdlib.h

As I said above, library uses HEAP memory. If you use Keil uVision and startup files provided from ST or if you downloaded it from my Github or default Keil uVision project, then HEAP memory is by default set to 0x200 Bytes = 512kB which can be quite small for something like strings can be in size.

So, in case of Keil uVision, you can open .s (startup file) inside your project and edit variable “Heap_Size” to a value you want to reserve for HEAP.

Functions and enumerations

Example

Project is available on my Github account, download library below.

tilz0R

Owner of this site. Application engineer, currently employed by STMicroelectronics. Exploring latest technologies and owner of different libraries posted on Github.

You may also like...