ATMega128 with FreeRTOS
Renoster requires a fairly integrate control system, with several tasks required to run almost simultaneously, e.g. position calculation, way point tracking, mapping etc. and others need to be able to interrupt those in the event of possible danger, e.g. collision detection, tilt detection etc. A preemptive multitasking OS such as FreeRTOS provides all these features.
FreeRTOS has several official ports available including the ATMega32, which was surprisingly easy to port to the ATMega128.
The starting point was CYPAX.net which had a great demo. However it does not include an AVRStudio project. But getting it working in AVR Studio was very simple.
1. Download FreeRTOS
2. Extract, e.g. C:\Development\Renoster\Embedded\FreeRTOS
3. Create a new AVRStudio project
4. Add the following files to your project
C:\Development\Renoster\Embedded\FreeRTOS\Source\croutine.c
C:\Development\Renoster\Embedded\FreeRTOS\Source\list.c
C:\Development\Renoster\Embedded\FreeRTOS\Source\queue.c
C:\Development\Renoster\Embedded\FreeRTOS\Source\tasks.c
C:\Development\Renoster\Embedded\FreeRTOS\Source\portable\MemMang\heap_1.c
C:\Development\Renoster\Embedded\FreeRTOS\Source\portable\GCC\ATMega323\port.c
FreeRTOSConfig.h from the demo from CPAX.net, remember to update as needed.
5. Add the following to the Include File Search Path in Project Options
C:\Development\Renoster\Embedded\FreeRTOS\Source\include\
C:\Development\Renoster\Embedded\FreeRTOS\Source\
C:\Development\Renoster\Embedded\FreeRTOS\Source\portable\GCC\ATMega323\
Lastly a simple test:
#include <stdint.h> #include <stdlib.h> #include <stdio.h> #include <stdbool.h> #include <string.h> #include <math.h> #include <avr/io.h> #include <avr/interrupt.h> #include <avr/eeprom.h> #include <avr/pgmspace.h> //FreeRTOS include files #include "FreeRTOS.h" #include "task.h" #include "croutine.h" void LedHeartBeatTask() { DDRG |= 1; for(;;) { PORTG |= _BV(PG0); vTaskDelay(500); PORTG &= ~_BV(PG0); vTaskDelay(500); } } void StartLedHeartBeatTask(unsigned portBASE_TYPE Priority) { // Spawn the task. xTaskCreate(LedHeartBeatTask, (signed portCHAR *)"LedHeartBeatTask", configMINIMAL_STACK_SIZE, NULL, Priority, NULL ); } portSHORT main(void) { //Start Tasks StartLedHeartBeatTask(tskIDLE_PRIORITY + 1); //RunSchedular vTaskStartScheduler(); return 0; }
Sample project files:

