You are on page 1of 2

Radek Dostl 4 you

FreeRTOS 6.1.0 minimal example


Mon, 11/08/2010 - 18:18 | dasty
Suppose you have following main.c and it works properly
#include <stdio.h> // prototype declarations for I/O functions
#include "uart.h"
int main (void)
{
vUartInit();
printf ("Hello World\n");
for (;;);
}
and you want to make minimalistic FreeRTOS example on your processor.
You will need to do following.
1. Link following sources to your project
=> FreeRTOS/Source/list.c
=> FreeRTOS/Source/queue.c
=> FreeRTOS/Source/tasks.c
=> FreeRTOS/Source/portable/MemMang/heap_YOUR_HEAP.c
=> FreeRTOS/Source/portable/YOUR_PORT/port.c
=> FreeRTOS/Source/portable/YOUR_PORT/portASM.s
2. Copy FreeRTOSConfig.h from closest demo example to your include path
3. Add following directories to you include path
=> FreeRTOS\Source\include
4. You may need to change Startup.S to the one from closest demo example, if threads are not starting
5. Modify your main.c to contain:
/* Standard includes */
#include <stdio.h> // prototype declarations for I/O functions
/* Driver includes */
#include "uart.h"
/* Scheduler includes */
#include "FreeRTOS.h"
#include "task.h"
void prvTaskA (void* pvParameters)
{
(void) pvParameters; // Just to stop compiler warnings.

for (;;) {
vTaskDelay(500);
printf("Task A\n");
vTaskDelay(500);
}
}
void prvTaskB (void* pvParameters)
{
(void) pvParameters; // Just to stop compiler warnings.
for (;;) {
printf("Task B\n");
vTaskDelay(1000);
}
}
int main (void)
{
vUartInit();
xTaskCreate( prvTaskA, ( signed char * ) "TaskA", configMINIMAL_STACK_SIZE, NULL,
tskIDLE_PRIORITY, ( xTaskHandle * ) NULL );
Contact information
rd@radekdostal.com
+43 681 815 945 10
skype: radekdostal
Blog CV Projects Contact
www.mi mo-domov.cz - Czech and Sl ovak peopl e abroad
xTaskCreate( prvTaskB, ( signed char * ) "TaskB", configMINIMAL_STACK_SIZE, NULL,
tskIDLE_PRIORITY, ( xTaskHandle * ) NULL );
vTaskStartScheduler();
//should never get here
printf("ERORR: vTaskStartScheduler returned!");
for (;;);
}
Add new comment
Copyright 2008 Radek Dostl. All Rights Reserved.

You might also like