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


ARM with edge triggered vPreemptiveTick ISR

Posted by David Farrell on August 15, 2008

I have found that edge trigger interrupts work better (at least with my
rev of a AT91SAM7X256). One caveat, the SAM7 AIX is supposed to clear ICCR
automatically (which is why I switched to edge in the first place) but I
seem to need to add:
"AT91C_BASE_AIC->AIC_ICCR = (0x1 << AT91C_ID_SYS);" to get it to work, maybe
I'm doing something else wrong?

By adding the above I was able to xTaskCreate( vQEITask,...) the same
vQEITask twice. This task toggles a pin every 10ms. I can see on a
scope the second instance toggles about 35us after the first, works
great, every 10ms two pulses. If I use level interrupts the second
instance of the task does not seem to run. My guess is that one of the
interrupts is being missed...

Anyone else have similar experiences?


RE: ARM with edge triggered vPreemptiveTick ISR

Posted by Richard on August 15, 2008
Thanks for the info.

To be honest I cannot remember why I went for level rather than edge, maybe I copied the code from somewhere. I know that my SAM7X devices were pre-production (seemed I got them months before they were publicly available) and had various errata - maybe that is it. Can you post your changes here?


RE: ARM with edge triggered vPreemptiveTick ISR

Posted by David Farrell on August 15, 2008
Sorry about the pieces. Since I'm trying to match
Atmel lib boards/components etc layout and I'm using
CodeSourcery G++ personal edition there are many changes
for layout alone diff's are not too useful. Ultimately I
plan on using the AT91SAM9XE256 in my design. I plan
on contributing both ports when done.

You should know, I have not tested vNonPreemptiveTick
with this!

Also as shown with ulFractional below I am looking to use the
AT91C_BASE_PITC->PITC_PIVR register as a fractional tick
counter. This in combination with your xTickCount gives a
precise time stamp. I want to sync multiple board ticks via
gps 1pps and/or IEEE-1588. Most other chips support similar
reads of the counter although many down-count.

In port.c:

#define portINT_PRIORITY 6

static void prvSetupTimerInterrupt( void )
#if configUSE_PREEMPTION == 0
( void (*)(void) ) vPreemptiveTick );

In portISR.c

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

ulFractionalClock = AT91C_BASE_PITC->PITC_PIVR; /* clear PITS bit in PIT_SR */

/* The following should be automatic with edge, but nogo ARGH! */

/* Increment the tick count - this may wake a task. */

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

/* End the interrupt in the AIC. In board_cstartup handler. */




RE: ARM with edge triggered vPreemptiveTick ISR

Posted by David Farrell on August 17, 2008
After reviewing my code I have one more thought to add.
One possible reason to use level vs edge is that more than one
source may cause the interrupt. The level is cleared when you
clear all possible sources. Edge does not have this option.
I only use the PIT interrupt with AT91C_ID_SYS.

[ 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