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

FreeRTOS 4.0.4, AT91SAM7X256, Timertick

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

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. */
portSAVE_CONTEXT();

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

serveDBGUFunc(); /* N E W */

/* Find the highest priority task that is ready to run. */
vTaskSwitchContext();

/* Clear PITS and end the interrupt in the AIC. */
AT91C_BASE_AIC->AIC_EOICR = AT91C_BASE_PITC->PITC_PIVR;

portRESTORE_CONTEXT();
}

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

Regards

Thomas

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.

Regards.

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;

AT91C_DBGU_CSR_Val = *AT91C_DBGU_CSR;
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.
Regards
Thomas

RE: FreeRTOS 4.0.4, AT91SAM7X256, Timertick

Posted by Thomas K.-H. Nittel on July 19, 2006
Hi,
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.
Regards
Thomas


[ 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