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

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