Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

Bobi

Member Since 19 Sep 2011
Offline Last Active Nov 14 2011 09:21 PM
-----

Topics I've Started

FreeRTOS handling hardware interrupts

09 November 2011 - 02:32 PM

Hello,

I want to run a FreeRTOS program on my Netduino plus board. I'm working on the ARM7 uIP demo for IAR (uIP_Demo_IAR_ARM7) that's provided with the FreeRTOS source code. 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.
The netduino has an onaboard button (PA29) and I want to initialise and handle the interrupts 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.

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 );
        }
        else
        {
                AT91F_PIO_SetOutput( AT91C_BASE_PIOA, LED1 );					
        }  
}

And in the prvSetupHardware function I have added the following:
        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);
        AT91F_AIC_EnableIt(AT91C_BASE_PIOA, AT91C_ID_PIOA);

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

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.