AT91SAM7S and ADC interrupt

Posted by Felipe on November 25, 2009
Hi,

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:

adcconfig.c

#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<;
}

}
AT91C_BASE_AIC->AIC_EOICR = 0;
}


void setupAD (void){

ADC_Initialize( AT91C_BASE_ADC,
AT91C_ID_ADC,
AT91C_ADC_TRGEN_DIS,
0,
AT91C_ADC_SLEEP_NORMAL_MODE,
AT91C_ADC_LOWRES_10_BIT,
BOARD_MCK,
BOARD_ADC_FREQ,
10,
1200);

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);
IRQ_EnableIT(AT91C_ID_ADC);
}

adcISR.s79

RSEG ICODE:CODE
CODE32

EXTERN vAdcISR
PUBLIC vAdcISREntry

; 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"

vAdcISREntry

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.

END


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?

Regards.