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


AT91SAM7S and ADC interrupt

Posted by Felipe on November 25, 2009

I'm a little bit confused abou using interrupt.

I've been trying to configure a ADC data ready interrupt with freertos, but it doesn' t work correctly.

So , here my code:


#include "adcconfig.h"

static unsigned int chns[] = {ADC_NUM_1, ADC_NUM_2, ADC_NUM_3, ADC_NUM_4,ADC_NUM_5,ADC_NUM_6,ADC_NUM_7,ADC_NUM_8};

extern void vAdcISREntry( void );

__arm void vAdcISR( void );

__arm void vAdcISR( void )
unsigned int status, i;

status = ADC_GetStatus(AT91C_BASE_ADC);

for(i=0;i<8;i++) {

if (ADC_IsChannelInterruptStatusSet(status, chns)) {
ADC_DisableIt(AT91C_BASE_ADC, 1<);//disable EOCx interrupt
conversionDone |= 1<;


void setupAD (void){

ADC_Initialize( AT91C_BASE_ADC,

ADC_EnableChannel(AT91C_BASE_ADC, ADC_NUM_1);
ADC_EnableChannel(AT91C_BASE_ADC, ADC_NUM_2);
ADC_EnableChannel(AT91C_BASE_ADC, ADC_NUM_3);
ADC_EnableChannel(AT91C_BASE_ADC, ADC_NUM_4);
ADC_EnableChannel(AT91C_BASE_ADC, ADC_NUM_5);
ADC_EnableChannel(AT91C_BASE_ADC, ADC_NUM_6);
ADC_EnableChannel(AT91C_BASE_ADC, ADC_NUM_7);
ADC_EnableChannel(AT91C_BASE_ADC, ADC_NUM_8);

IRQ_ConfigureIT(AT91C_ID_ADC, 0, ( void (*)( void ) ) vAdcISR);




; Wrapper for the serial port interrupt service routine. This can cause a
; context switch so requires an assembly wrapper.

; Defines the portSAVE_CONTEXT and portRESTORE_CONTEXT macros.
#include "ISR_Support.h"


portSAVE_CONTEXT; Save the context of the current task.

blvAdcISR; Call the ISR routine.

portRESTORE_CONTEXT; Restore the context of the current task -
; which may be different to the task that
; was interrupted.


I started AD in main before my tasks, and inside a task i want to get de ADC value each 1 second for example.

when i run getMeasure in my task, the program freeze and i get data abort exception .

So, what i supossed to do ?

Thanks !

RE: AT91SAM7S and ADC interrupt

Posted by Richard on November 25, 2009
Have you got the ADC working in a simple application with out FreeRTOS?

Could it be that the ADC interrupt is executing before the scheduler has been started?


[ 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