Quality RTOS & Embedded Software

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


FreeRTOS 4.0.4, AT91SAM7X256, Timertick

Posted by Thomas K.-H. Nittel on July 19, 2006

FreeRTOS 4.0.4 uses on AT91SAM7X256 the Periodic Interval Timer (PIT) which triggers the system interrupt (sys_irq). But sys_irq is triggered by some other peripherals as well like Debug Unit (DBGU), or Watchdog Timer (WDT). So 'vTaskIncrementTick' is allowed to be called only if the interrupt is triggered by the PIT. If the interrupt is triggered by another peripheral a hook function should be called. As I use the DBGU I had to modify the function 'void vPreemptiveTick( void )' as follows

void vPreemptiveTick( void ) __attribute__((naked));
void vPreemptiveTick( void )
/* Save the context of the current task. */

/* Increment the tick count - this may wake a task. */
if ((AT91C_BASE_PITC->PITC_PISR & AT91C_PITC_PITS) > 0) /* N E W */

serveDBGUFunc(); /* N E W */

/* Find the highest priority task that is ready to run. */

/* Clear PITS and end the interrupt in the AIC. */


Perhaps you may want to adopt these modifications to FreeRTOS.

Hardware details can be found in Atmel's manual 'AT91 ARM Thumb-based Microcontrollers AT91SAM7X256/AT91SAMX128 Preliminary', Version '6120D-ATARM-02-Feb-06' (document name 'doc6120.pdf'), fig. 10-1 'System Controller Block Diagram (http://www.atmel.com/dyn/resources/prod_documents/6120s.pdf).



RE: FreeRTOS 4.0.4, AT91SAM7X256, Timertick

Posted by Nobody/Anonymous on July 19, 2006
This is one of the benefits of open source!

Ways of using DBGU with the PIT was discussed here recently, but I cannot provide a reference as the search facility seems to have stopped working on the forum (anybody else seeing this?).

The tick interrupt could be generated off a different timer if that was preferable to you.

In your solution you are effectively polling the DBGU, is this correct? If you want the DBGU to generate interrupts itself then you have to check the source of the interrupt from within the ISR so as not to increment the tick on DBGU interrupts.

RE: FreeRTOS 4.0.4, AT91SAM7X256, Timertick

Posted by Richard on July 19, 2006
Sharing interrupts like this on a peripheral such as the PIT is a pain as by its nature you want it to be frequent and fast. I think the way people do this is to check the source of the interrupt from within the ISR, and then service whichever is found to be the cause.

Your solution looks fine provided the debug interface does not itself cause any interrupts.


RE: FreeRTOS 4.0.4, AT91SAM7X256, Timertick

Posted by Thomas K.-H. Nittel on July 19, 2006
Hi, Richard,

why shouldn't the DBGU generate interrupts in my case?
The DBGU does generate interrupts for me. But there is no function call to 'serveDBGUFunc' because this function is declared as inline in my file 'dbguISR.h' which is included in 'portISR.c'. So there is no function call overhead.

Here is the definition of the function:

void serveDBGUFunc(void);
extern inline void serveDBGUFunc(void)
unsigned AT91C_DBGU_CSR_Val;

if (((AT91C_DBGU_CSR_Val & AT91C_US_TXRDY)!=0))
if ((AT91C_DBGU_CSR_Val & AT91C_US_RXRDY)!=0)

I don't like to modify the original FreeRTOS code because I must repeat my modifications with every new FreeRTOS version. I would prefer a hook function in the function 'vPreemptiveTick' or another smart solution which doesn't require me to touch the original FreeRTOS code.

RE: FreeRTOS 4.0.4, AT91SAM7X256, Timertick

Posted by Thomas K.-H. Nittel on July 19, 2006
no, I don't poll the DBGU. The DBGU generates interrupts. I do check which peripheral generate the interrupt. That is why I inserted the line 'if ((AT91C_BASE_PITC->PITC_PISR & AT91C_PITC_PITS) > 0)'.
For further details see my posting following 'RE: FreeRTOS 4.0.4, AT91SAM7X256, Timertick' from richardbarry at 2006-07-19 05:40.

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

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

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


FreeRTOS and other embedded software careers at AWS.

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