Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


FreeRTOS on ATmega168

Posted by Uwe Fechner on March 25, 2006

I am trying to get FreeRTOS working on the ATmega168, a chip with 16 k FLASH and 1 kBytes RAM.

The program memory is no problem, the RAM usage is.

The following is working so far:


and the TX part of


Important for me is it, to get the RX part of the
COMTestTasks going.

My configuration:

#define configUSE_PREEMPTION1
#define configUSE_IDLE_HOOK0
#define configCPU_CLOCK_HZ( ( unsigned portLONG ) 8000000 )
#define configTICK_RATE_HZ( ( portTickType ) 512 )
#define configMAX_PRIORITIES( ( unsigned portBASE_TYPE ) 4 )
#define configMINIMAL_STACK_SIZE( ( unsigned portSHORT ) 85 )
#define configTOTAL_HEAP_SIZE ( (size_t ) (500 ) ) // default: 1500

#define configMAX_TASK_NAME_LEN( 4 ) // default: 8
#define configUSE_TRACE_FACILITY0
#define configUSE_16_BIT_TICKS1
#define configIDLE_SHOULD_YIELD1

/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */

#define INCLUDE_vTaskPrioritySet0
#define INCLUDE_uxTaskPriorityGet0
#define INCLUDE_vTaskDelete1
#define INCLUDE_vTaskCleanUpResources0
#define INCLUDE_vTaskSuspend0
#define INCLUDE_vTaskDelayUntil1
#define INCLUDE_vTaskDelay1

WinAVR reports: (I am using avr-gcc version 3.4.5)

Program: 6390 bytes (39,0% Full)
(.text + .data + .bootloader)
Data: 689 bytes (67,3% Full)
(.data + .bss + .noinit)

I don't no yet, where this high ram usage is coming from.

Is it right, that statically allocated RAM and the HEAP_SIZE together must be less then 1k RAM?

Any hints, how I can optimize the RAM usage are welcome.

Uwe Fechner

RE: FreeRTOS on ATmega168

Posted by Richard on March 25, 2006
Yes, the HEAP_SIZE is statically allocated, so this together with the other statically allocated variables must be less than 1K.

1K is not very much.

On Monday FreeRTOS V4.0.0 will be available. This will give you the option to use co-routines in place of tasks, which could give you a big RAM saving if appropriate for your application. This might be better for you on a 1K device.


RE: FreeRTOS on ATmega168

Posted by Uwe Fechner on March 25, 2006
Well, it is working now.
(One blinking LED Task, RX and TX Tasks with 600 Bytes Heap).

My application shouldn't need more than 128 Bytes of RAM, so I can provide 800-872 Bytes for the heap. I hope that this is sufficient for five tasks with two priorities.

The heap size is included in the memory usage reported from avr-gcc (other than I thought).

My problem was, that a changed heap size was recognized by the compiler only if I run

make clean
make all

and not with a simple make all.

Nevertheless I am looking forward to the new release.


Uwe Fechner

RE: FreeRTOS on ATmega168

Posted by Uwe Fechner on March 27, 2006
The update to FreeRTOS 4.0 reduced the memory usage, even without using CoRoutines:

PROGRAM: 7262 Bytes
DATA: 981 Bytes

PROGRAM: 7122 Bytes
DATA: 931 Bytes

This is a reduced demo application with
six tasks.


Keep up the good work!

Uwe Fechner

RE: FreeRTOS on ATmega168

Posted by Uwe Fechner on April 1, 2006
I just published my FreeRTOS port in my wiki.


The code is not very clean and not very well documented yet.

When this is done, the port could be added to the distribution.

[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]

Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers


STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner