Quality RTOS & Embedded Software

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




Loading

PIO Interrupt Config

Posted by Allure99 on July 15, 2009
Hi,

I am working on AT91SAM7x and FreeRTOS5.0.4

Trying to read 100ms pulse using one of the PIOB and using the configuration below,
but alway got interrupt on both pulse in and pulse oput (alway reading 2 interrupt for single pulse)

Another thing is, I try to set the intrurrpt as positive edge trigger on AIC_SMR, but with the configuration, the intrruprt is not fire at all.

can any one help?

my setup code as follow:

//===================================================================================================
// ISR setup
//===================================================================================================

void Init_PIOB_isr(void)
{
extern void (vPIOB_ISR_Wrapper) ( void );


//Pulse_Count = 0;
Count_Ctrl.Count_On = COUNT_OFF;

portENTER_CRITICAL();

// Setup PIO
AT91C_BASE_PIOB->PIO_PER = AT91C_PIO_PB7; // Set in PIO mode.
AT91C_BASE_PIOB->PIO_ODR = AT91C_PIO_PB7; // Set to Input only (disable output).
AT91C_BASE_PIOB->PIO_IFER = AT91C_PIO_PB7; // input glith filter
//AT91C_BASE_PIOB->PIO_IER = AT91C_PIO_PB7; // Enable input change interupt.
AT91C_BASE_PIOB->PIO_CODR = AT91C_PIO_PB7; // clear
AT91C_BASE_PIOB->PIO_PPUDR = AT91C_PIO_PB7; // Pull up disable


// Config PMC
AT91C_BASE_PMC->PMC_PCER = 1 << AT91C_ID_PIOB;

// Setup ISR.
AT91C_BASE_AIC->AIC_IDCR = 1 << AT91C_ID_PIOB;// Disable the interrupt first

// Configure mode and handler
//AT91C_BASE_AIC->AIC_SMR[AT91C_ID_PIOB] = AT91C_AIC_PRIOR_HIGHEST | AT91C_AIC_SRCTYPE_POSITIVE_EDGE;
AT91C_BASE_AIC->AIC_SMR[AT91C_ID_PIOB] = AT91C_AIC_PRIOR_HIGHEST | AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL;
AT91C_BASE_AIC->AIC_SVR[AT91C_ID_PIOB] = (unsigned int) vPIOB_ISR_Wrapper;

AT91C_BASE_PIOB->PIO_IER = AT91C_PIO_PB7;

// Clear interrupt
AT91C_BASE_AIC->AIC_ICCR = 1 << AT91C_ID_PIOB;
// Enable interupt.
AT91C_BASE_AIC->AIC_IECR = 1 << AT91C_ID_PIOB;


portEXIT_CRITICAL();
}

//===================================================================================================
// Interrupt Handler
//===================================================================================================

void vPIOB_ISR_Wrapper( void )__attribute__ ((naked));
void vPIOB_ISR_Handler( void );

void vPIOB_ISR_Wrapper( void )
{
/* Save the context of the interrupted task. */
portSAVE_CONTEXT();
/* Call the handler.
to ensure the correct stack frame is set up. */
vPIOB_ISR_Handler();
/* Restore the context of whichever task is going to run next. */
portRESTORE_CONTEXT();
}

void vPIOB_ISR_Handler( void )
{

unsigned long status;

// Diabale interrupt
AT91C_BASE_AIC->AIC_IDCR = 1 << AT91C_ID_PIOB;
// Clear interupt.
AT91C_BASE_AIC->AIC_ICCR = 1 << AT91C_ID_PIOB;


status = (AT91C_BASE_PIOB -> PIO_ISR);
status &= (AT91C_BASE_PIOB -> PIO_IMR);

if (status & AT91C_PIO_PB7)
{

Pulse_Count++;

}
// Enable Interupt.
AT91C_BASE_AIC->AIC_IECR = 1 << AT91C_ID_PIOB;
AT91C_BASE_AIC->AIC_EOICR = 0;
}


RE: PIO Interrupt Config

Posted by Çağlar Akyüz on July 15, 2009
Sam7x PIO interrupts are by definition "Input change interrupt". So it is expected to receive interrupt for both rising and falling edges. You should discard one of them in your interrupt routine.

For your second problem, you can not select active edge of the interrupts. They are either edge triggered or level sensitive.

Caglar


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




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

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

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