Quality RTOS & Embedded Software

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


Loading

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.


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


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

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

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

Xilinx Microblaze and Zynq partner