LibC Example

Your introduction into FreeRTOS on the netX 90 with newlib c.

Download

Examples

Project Scope

The FreeRTOS Bare example aims to demonstrate FreeRTOS with newlib c on the netX 90 in the simplest possible way, and contains the following components:

  • CMSIS
  • FreeRTOS
  • netx_drv
  • newlib c

You have therefore access to FreeRTOS features, the netX peripheral drivers and library functions from newlib c (malloc, free, printf, etc.).

See section Porting Information if you require information about the link between the individual components.

Used configuration

The following table explains our configuration decisions:

ConfigurationStatement
Portable: ARM_CM3We do not require FPU or MPU
Heap: heap_useNewlibFor dynamic allocation, using newlib c
netX_drv: dynamic MutexSince we use dynamic allocation

Execution of the LibC Example

The LibC example consists of two tasks:

  1. helloWorld_task: uses the libC function printf() to print “Hello” and “World!” in a loop via UART. Between the messages is always a delay of 0.5 sec.
  2. anotherMessage_task: prints the message “Another Message!” in a loop with a delay of 0.2 sec.

The source code of the two tasks can be seen below:

helloWorld_task_code
  while(1)
  {
    /** print message */
    printf("Hello ");

    /** delay 500 ms */
    vTaskDelay(500);

    /** print message */
    printf("World!\r\n");

    /** delay 500 ms */
    vTaskDelay(500);
  }
anotherMessage_task_code
  while(1)
  {
    /** print message */
    printf("Another Message!\r\n");

    /** delay 200 ms */
    vTaskDelay(200);
  }

The printed output is the following:

As you can see, the message is print without line buffering (this feature is disabled by default in the libc_support package).