Quality RTOS & Embedded Software

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


Loading

AVR32_UC3's use of prvScheduleNextTick()

Posted by Rohit Grover on June 22, 2010
Hello,

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));
}


Vs.

__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)
{
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...

Regards.


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


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

Careers

FreeRTOS and other embedded software careers at AWS.


Latest News

FreeRTOS kernel V10.0.1 is available for immediate download. Now MIT licensed.


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