Quality RTOS & Embedded Software

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


ARM7 uIP Demo interrupts

Posted by Bobi on November 9, 2011
I'm working on the ARM7 uIP demo for IAR (uIP_Demo_IAR_ARM7) that's provided with the source. I know that this may be an easy question but I have lost too much time trying to do it on my own. I want to be able to handle PIO button interrupts.
I have a netduino plus board (with at91sam7x512) which has an onaboard button (PA29) and I want to initialise and handle the interrupt so that when you press the button the onboard LED (PB23) will turn ON.
I want to achieve this using the provided FreeRTOS at91sam7x256 port. I already have it working with the demos which come from the atmel site but they use a very different port which fails to work together with the FreeRTOS. I want to use the FreeRTOS port because the main goal of the application will be far different from turning LEDs on and off.

I have the FreeRTOS practical guide and I know that there is a whole chapter about interrupts but I didn't find out how can you handle a button press interrupt.


RE: ARM7 uIP Demo interrupts

Posted by Bobi on November 9, 2011
Here is my code:
First in board.h I have defined that LED1 is (1 << 23) and SW1 is (1 << 29).
I have the following interrupt handler, which will turn the onboard LED ON:

void Handler(void)
if( AT91F_PIO_GetInput( AT91C_BASE_PIOA ) & LED1 )
AT91F_PIO_ClearOutput( AT91C_BASE_PIOA, LED1 );
AT91F_PIO_SetOutput( AT91C_BASE_PIOA, LED1 );

And in the prvSetupHardware function I have added the following:

AT91F_PMC_EnablePeriphClock( AT91C_BASE_PMC, 1 << AT91C_ID_PIOA );
AT91F_PMC_EnablePeriphClock( AT91C_BASE_PMC, 1 << AT91C_ID_PIOB ) ;
AT91F_PMC_EnablePeriphClock( AT91C_BASE_PMC, 1 << AT91C_ID_EMAC ) ;

AT91F_PIO_CfgInput( AT91C_BASE_PIOA, SW1 );
AT91F_PIO_CfgPullup( AT91C_BASE_PIOA, SW1 );
AT91F_PIO_CfgInputFilter( AT91C_BASE_PIOA, SW1 );

AT91F_AIC_ConfigureIt(AT91C_BASE_PIOA, AT91C_ID_PIOA, 0x07, 0x0, Handler);

And here I am confused about am I initializing the interrupt properly? As long as the button belongs to PA29 I know that I have to use the AT91C_BASE_PIOA when I make the call to AT91F_AIC_ConfigureIt. And here I am not sure about the irq_id parameter. Should it be 29 (as I am using PA29) or should it be AT91C_ID_PIOA? And if its AT91C_ID_PIOA where should I specify that I want to handle intterupts coming from PA29?

Thanks :)

RE: ARM7 uIP Demo interrupts

Posted by MEdwards on November 9, 2011
If you want help configuring the SAM7 hardware, I recommend asking your question on the SAM7 forum, or asking Atmel support. This is a FreeRTOS forum, and I cannot see how your question relates to FreeRTOS, so you are unlikely to have success asking here.

RE: ARM7 uIP Demo interrupts

Posted by Bobi on November 9, 2011
Well the thing is that I have all this already working using the port which Atmel have provided in their getting started tutorials. The problems comes when I want to use FreeRTOS with the port they have provided.

RE: ARM7 uIP Demo interrupts

Posted by Bobi on November 15, 2011
Hi, sorry about the trouble...
The problem was very strange for me. I would be very happy if someone with more experience in FreeRTOS could explain it.

So the problem was in the way I am configuring the interrupt - exactly when I make the call:

AT91F_AIC_ConfigureIt(AT91C_BASE_PIOA, AT91C_ID_PIOA, 0x07, 0x0, Handler);

If I chnage this to


I have no idea why it didn't work when I activated the interrupt on the AT91C_BASE_PIOA.
Could someone explain what thoes the AT91C_AIC_SRCTYPE_EXT_LOW_LEVEL value mean?

Thanks a lot!

RE: ARM7 uIP Demo interrupts

Posted by Richard on November 15, 2011
Happy to hear you have it working.

“Could someone explain what thoes the AT91C_AIC_SRCTYPE_EXT_LOW_LEVEL value mean?”

It is a long time since I have used that library, but from my recollection it is explained in the library comments, and in the documentation, so with respect, you can read it yourself. It is definitely not a FreeRTOS related question.


RE: ARM7 uIP Demo interrupts

Posted by Bobi on November 15, 2011
OK, sorry about that... :) it looked so confising the first time, but now I fonund some documentation from Atmel that will help.

Best Regards

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

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

Latest News

FreeRTOS v10.2.0 is available for immediate download. MIT licensed, and including RISC-V and ARMv8-M (Cortex-M33) demos.

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

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

Cadence Tensilica Cortes

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