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


AVR32_UC3's use of prvScheduleNextTick()

Posted by Rohit Grover on June 22, 2010

I'm working with AVR32_UC3 and GCC. I've got a FreeRTOS port from Atmel at version 6.0.0; and it seems to work fine for a simple app which blinks LEDs.
I want to upgrade to 6.0.5; but my led-blinker app fails.
The problem is caused by the changes in port.c to the mechanism used to generate ticks.
It has to do with prvScheduleNextTick(); which replaces the previous scheme implemented by prvClearCcInt().

I'll include the code from the two:

__attribute__((__noinline__)) static void prvClearCcInt(void)
Set_system_register(AVR32_COMPARE, Get_system_register(AVR32_COMPARE));


__attribute__((__noinline__)) static void prvScheduleNextTick(void)
unsigned long lCycles, lCount;

lCycles = Get_system_register(AVR32_COMPARE);
lCycles += (configCPU_CLOCK_HZ/configTICK_RATE_HZ);
// If lCycles ends up to be 0, make it 1 so that the COMPARE and exception
// generation feature does not get disabled.
if(0 == lCycles)
lCount = Get_system_register(AVR32_COUNT);
if( lCycles < lCount )
{// We missed a tick, recover for the next.
lCycles += (configCPU_CLOCK_HZ/configTICK_RATE_HZ);
Set_system_register(AVR32_COMPARE, lCycles);

Reverting port.c in 6.0.5 to use prvClearCcInt() makes everything work like normal.

On the surface, it seems that prvScheduleNextTick() certainly has a minor bug about not taking counter wrap-around into consideration--when the COMPARE register value wraps around due to the increment we might end up generating the next tick TWO ticks later. But I can't figure out why my app completely fails to work with the new scheme.

Can someone please help? Thanks.

RE: AVR32_UC3's use of prvScheduleNextTick()

Posted by Rohit Grover on June 22, 2010
And could someone please explain to me how the previous scheme worked (i.e. the one using prvClearCcInt). Does setting the COMPARE register to itself reset the COUNT register?

RE: AVR32_UC3's use of prvScheduleNextTick()

Posted by Richard on June 22, 2010
The files in the FreeRTOS download are designed for the original ES version of the AVR32, whereas the files in the AVR32 Atmel Software Framework (available from atmel.com) are designed for the latest AVR32 chips. The ES versions are now somewhat obsolete, and my advice is to use the files from Software Framework V1.7.0. The AVR32 files have not been updated between V6.0.0 and V6.0.5 so I don't think you will have any problems there.

There is actually a new AVR32 port being created at the moment to add a bit of extra functionality, and the original files have actually been removed from the FreeRTOS SVN repository already. I can't promise a completion date yet - but watch this space...


[ 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