cancel
Showing results for 
Search instead for 
Did you mean: 

ADC - Interrupt but no data

nik
Associate II
Posted on February 05, 2008 at 11:43

ADC - Interrupt but no data

2 REPLIES 2
nik
Associate II
Posted on May 17, 2011 at 09:49

Hi folks,

I just don't get it: I configured the ADC according to the reference sheet. The ADC does start the conversion and produces an ECVI. But there are no data (voltage was about 2,2V). Here is my code (relevant parts):

/*********** CODE ***********/

init_peripherals.c:

(...)

void init_ADC(void){

// Clock for ADC

SCU->PRR1 |= 0x00040800;

SCU->PCGR1 |= 0x00040800;

// Configure channels

ADC->CCR = 0x000C;

// RESET

// Set GPIOANA for 4.1

SCU->GPIOANA = 0x0002;

// configure options

ADC->CR |= 0x0440; // ECVI enable, single channel mode on ch1, one shot mode

// Set POR

ADC->CR |= 0x0002;

// wait 1ms

wait(1000);

// STANDBY

// clear STB

ADC->CR &= 0xFFF7;

// wait 15 us

wait(15);

// IDLE

// conversion needs to be started by setting STR

}

void init_VIC(void){

/* VICx_INTSR, set corresponding bit [0: IRQ; 1: FIQ]

* VICx_VCiR, enable corresponding register with 0x20 and pass IRQ# to 0:4

* VICx_VAiR, pass address of ISR

* VICx_INTER, set corresponding bit [0: dis; 1: ena]

*/

// Clock for VIC

SCU->PRR0 |= 0x0020;

SCU->PCGRO |= 0x0020;

// Interrupt for ADC

VIC0->VCiR[15] = 0x20;

VIC0->VCiR[15] |= 15;

VIC0->VAiR[15] = (unsigned int)ADC_IRQHandler;

VIC0->INTER |= 0x8000;

}

main.c:

(...)

// measure U_LDR_offen

ADC->CR |= 0x0001;

wait(500);

(...)

/*********** END OF CODE ***********/

Do I need to set GPIO4.1 to Alternate Input (internal peripheral connected)? This is what they do in the Blinky-example. Haven't tried this yet.

HARDWARE:

Keil MCBSTR-9 (STR912FW44)

Keil uvision

Cheers

Nik

amira1
Associate II
Posted on May 17, 2011 at 09:49

Hello Liqnik,

''Do I need to set GPIO4.1 to Alternate Input (internal peripheral connected)?''

No you should configure the GPIO in analog input mode. However, you can only configure it in analog mode (in SCU_GPIOANA register) since the GPIO has the input as the default mode.

Could you please refer to the v2.0 library to the first example of the ADC (the end of conversion interrupt is used).

Best regards,

mirou