Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

Kernel modification

Posted by emgi2008 on November 20, 2008
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!
;PD0=odo-left
;PD1-odo-right
begin:
in r16,PIND
mov r17,r16
lds r18,pdstore ;temp byte that contains the previous status of PIND

eor r16,r18
bst r16,0
brtc right

left: ;maintain a 16bit unsigned counter
lds r19,leftcnt00
inc r19
sts leftcnt00,r19
brne right
lds r20,leftcnt01
inc r20
sts leftcnt01,r20

right: ;maintain a 16bit unsigned counter
bst r16,1
brtc ready

lds r19,rightcnt00
inc r19
sts rightcnt00,r19
brne ready
lds r20,rightcnt01
inc r20
sts rightcnt01,r20

ready:
sts pdstore,r17
rts

Regards,
emgi

RE: Kernel modification

Posted by Dave on November 21, 2008
You can add code into the tick interrupt using the tick hook.

Set configUSE_IDLE_HOOK to 1 in FreeRTOSConfig.h. Then define a function called vApplicationTickHook() into which you put your code. You might have to define this as an assembly function in your case, or a naked C function that has inline assembly code in it.

RE: Kernel modification

Posted by emgi2008 on November 21, 2008
Thanks a tonne!
Assembly programming is not an issue for me but I am having trouble with the ins & outs of WinAVR GCC and I am pretty new to FreeRTOS as well.
I guess that I will find out how to do this sooner or later and learn a lot on the way.

RE: Kernel modification

Posted by emgi2008 on November 21, 2008
You probably meant: configUSE_TICK_HOOK?


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




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists