Currently I am considering the application of FreeRTOS for a robotics project. The processor of choice would be the ATmega128 which is an 8 bit AVR risc processor.
One of the most vital tasks would be keeping track of the odometry. A black/white disc turns on the motor-axle and this movement is registered by a sensor.
This can be accomplished in several ways:
1: using hardware-counters and read these in using a port but 8 IO lines is a lot on an MCU like this.
2: Connect the motion-sensor directly to an input. This solution would only take uo two IO lines and is hence more attractive, at least to me.
The interval at which the IO lines need to be monitored is almost as high as the kernel tick-rate (500-1000Hz) Writing a task for this seems a bad idea as it would leave no timeslots for other processes to run. Instead, I was considering to run the poll routine as part of the tick-interrupt. Using AVR assembly would consume an extra 20-40 cycles at most.
Altough this overhead is incorporated in each tick-cycle, this seems a more viable solution than writing a dedicated task that should run every 10ms or so. My proposed code is below but I am curious to find about other solutions to this challenge.
Tips about how and where to add (port.c?) this code to FreeRTOS are most welcome also!
lds r18,pdstore ;temp byte that contains the previous status of PIND
left: ;maintain a 16bit unsigned counter
right: ;maintain a 16bit unsigned counter