cancel
Showing results for 
Search instead for 
Did you mean: 

ADC fake interrupt on STR736

cialdi
Associate II
Posted on March 12, 2008 at 11:49

ADC fake interrupt on STR736

1 REPLY 1
cialdi
Associate II
Posted on March 12, 2008 at 11:49

I use 6 channel in scan mode and I setup them in this way (MCLK is 36 MHz)

Code:

static void initAd(void)

{

GPIO_InitTypeDef GPIOx_InitStructure;

ADC_InitTypeDef ADC_InitStructure;

/*-----------------------------------GPIO3 ----------------------------------*/

/* GPIO3 Clock Enable */

CFG_PeripheralClockConfig(CFG_CLK_GPIO3, ENABLE);

/* GPIO3 Configuration */

GPIOx_InitStructure.GPIO_Mode = GPIO_Mode_HI_AIN_TRI;

GPIOx_InitStructure.GPIO_Pins = GPIO_PIN_4 | // AIN0

GPIO_PIN_5 | // AIN1

GPIO_PIN_6 | // AIN2

GPIO_PIN_7 | // AIN3

GPIO_PIN_8 | // AIN4

GPIO_PIN_9; // AIN5

GPIO_Init (GPIO3, &GPIOx_InitStructure);

/*---------------------------------ADC---------------------------------------*/

/* ADC Clock Enable */

CFG_PeripheralClockConfig(CFG_CLK_ADC, ENABLE);

/* ADC Configuration */

ADC_StructInit(&ADC_InitStructure);

ADC_InitStructure.ADC_Calibration = ADC_Calibration_OFF;

ADC_InitStructure.ADC_AutoClockOff = ADC_AutoClockOff_Disable ;

ADC_InitStructure.ADC_ConversionMode = ADC_ConversionMode_Scan ;

ADC_InitStructure.ADC_SamplingPrescaler = 0x7; // Inutile ma 36/14=2.571 MHz

ADC_InitStructure.ADC_ConversionPrescaler = 0x7; // 36/14 = 2.571 MHz

// sampling time 11.33 us (1 ch); 70 us (6 ch)

ADC_InitStructure.ADC_FirstChannel = ADC_CHANNEL0 ;

ADC_InitStructure.ADC_ChannelNumber = 6;

ADC_Init(&ADC_InitStructure);

/* EOC interrupt Enable */

EIC_IRQChannelConfig( ADC_IRQChannel , ENABLE );

EIC_IRQChannelPriorityConfig( ADC_IRQChannel, 1);

ADC_ITConfig(ADC_IT_ECH , ENABLE);

/* Enable ADC */

ADC_Cmd(ENABLE);

}

The interrupt handler is something like this

Code:

void ADC_IRQHandler(void);

void ADC_IRQHandler(void)

{

if(ADC->PBR == 0)

{

while(1) GPIO0->PD ^= 16; // output a signal

}

/* Clear ECH Interrupt pending bit */

ADC_FlagClear (ADC->PBR);

// some stuff

}

with my oscilloscope I can see that after a while the program loops in while(1). It seems that is raised an interrupt without any panding bit set.

Is it possible?

Is the adc well configured?

What is wrong with code I wrote?

thanks