2009-01-28 06:20 PM
Unable to get ADC INTERRUPT
2011-05-17 04:00 AM
i am trying to get ADC reading in interrupt.i have kept adc in continuous conversion mode, with EOC interrupt enabled.
i assumed that i should get interrupt after each EOC from where i can then collect the ADC reading. but i have been unable to get any interrupt from ADC. i checked the ADC by polling, where i get correct the reading. i am using RIDE 7 with GCC. and ST library functions. NVIC CONFIGURATION NVIC_InitStructure.NVIC_IRQChannel = ADC1_2_IRQChannel; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;//0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); ADC_ITConfig(ADC1, ADC_IT_EOC, ENABLE); ADC CONFIGURATION GPIO_InitTypeDef GPIO_InitStructure; ADC_InitTypeDef ADC_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; GPIO_Init(GPIOC, &GPIO_InitStructure); ADC_InitStructure.ADC_Mode = ADC_Mode_Independent; ADC_InitStructure.ADC_ScanConvMode = DISABLE; ADC_InitStructure.ADC_ContinuousConvMode = ENABLE; ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None; ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; ADC_InitStructure.ADC_NbrOfChannel = 1; ADC_Init(ADC1, &ADC_InitStructure); ADC_RegularChannelConfig(ADC1, ADC_Channel_14, 1,ADC_SampleTime_239Cycles5); ADC_Cmd(ADC1, ENABLE); ADC_ResetCalibration(ADC1); while(ADC_GetResetCalibrationStatus(ADC1)!= RESET); ADC_StartCalibration(ADC1); while(ADC_GetCalibrationStatus(ADC1) != RESET); interrupt handler void ADC1_2_IRQHandler(void) { if(ADC_GetITStatus(ADC1, ADC_IT_EOC) != RESET) { ADC_TEMP1 = ADC_GetConversionValue(ADC1)&0x0FFF; } } i trigger ADC using ADC_SoftwareStartConvCmd(ADC1, ENABLE); after this i assume i should get interrupt on each conversion. i guess i am missing something. but dont know what. thanks in advance. pavan k [ This message was edited by: pavan.karmakar on 28-01-2009 06:38 ]2011-05-17 04:00 AM
Hello, I have a similar problem. Im trying to convert the ADCs with DMA but Im having no DMA interrupt. Not sure if the ADC is working. I also posted in the forum:
. I also sent a technical question to ST as I still did not have a reply from the forum. If a get a technical answer from ST, I will send it to you. Thanks Johann2011-05-17 04:00 AM
Hello. I still have no answer from St technical support. In the meantime Im working to fix the line. I will notify you. thanks. To tell you the truth, I ran out of ideas, as followed examples. Im feeling in the corner :)
2011-05-17 04:00 AM
i am right now trying to get the ADC working using DMA, i will update on successful implementation.
thank you pavan k2011-05-17 04:00 AM
Hello, I have a similar problem. Im trying to convert the ADCs with DMA but Im having no DMA interrupt. Not sure if the ADC is working. I also posted in the forum:
. I also sent a technical question to ST as I still did not have a reply from the forum. If a get a technical answer from ST, I will send it to you. Thanks Johann2011-05-17 04:01 AM
Hi jgalea;
I have the following code that works correctly (ADC-DMA): int main(void) { #ifdef DEBUG debug(); #endif /* System clocks configuration ---------------------------------------------*/ RCC_Configuration(); /* NVIC configuration ------------------------------------------------------*/ NVIC_Configuration(); /* GPIO configuration ------------------------------------------------------*/ GPIO_Configuration(); /* DMA1 channel1 configuration ----------------------------------------------*/ DMA_DeInit(DMA1_Channel1); DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)ADC1_DR_Address; DMA_InitStructure.DMA_MemoryBaseAddr = (u32)ADCConvertedValue; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; DMA_InitStructure.DMA_BufferSize = NumberOfSample; DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord; DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; DMA_InitStructure.DMA_Priority = DMA_Priority_High; DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; DMA_Init(DMA1_Channel1, &DMA_InitStructure); /* Enable DMA1 channel1 */ DMA_Cmd(DMA1_Channel1, ENABLE); /* Enable DMA Transfer complete interrupt */ DMA_ITConfig(DMA1_Channel1, DMA_IT_TC, ENABLE); /* ADC1 configuration ------------------------------------------------------*/ ADC_InitStructure.ADC_Mode = ADC_Mode_Independent; ADC_InitStructure.ADC_ScanConvMode = ENABLE; ADC_InitStructure.ADC_ContinuousConvMode = ENABLE; ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None; ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; ADC_InitStructure.ADC_NbrOfChannel = 1; ADC_Init(ADC1, &ADC_InitStructure); /* ADC1 regular channel14 configuration */ ADC_RegularChannelConfig(ADC1, ADC_Channel_13, 1, ADC_SampleTime_1Cycles5); /* Enable ADC1 DMA */ ADC_DMACmd(ADC1, ENABLE); /* Enable ADC1 */ ADC_Cmd(ADC1, ENABLE); /* Enable ADC1 reset calibaration register */ ADC_ResetCalibration(ADC1); /* Check the end of ADC1 reset calibration register */ while(ADC_GetResetCalibrationStatus(ADC1)); /* Start ADC1 calibaration */ ADC_StartCalibration(ADC1); /* Check the end of ADC1 calibration */ while(ADC_GetCalibrationStatus(ADC1)); /* Start ADC1 Software Conversion */ ADC_SoftwareStartConvCmd(ADC1, ENABLE); while (1) { if (PrintFlag == 1) { printf(''%d\n'',ADC_Average); PrintFlag = 0; } } //////////////// DMA IRQ routine ////////////////////// void DMA1_Channel1_IRQHandler(void) { for (n=0; n { ADC_Sum = ADC_Sum + ADCConvertedValue[n]; } ADC_Average = ADC_Sum/NumberOfSample; ADC_Sum=0; PrintFlag = 1; DMA_ClearFlag(DMA1_FLAG_TC1); } } //////////////// NVIC config ////////////////////// void NVIC_Configuration(void) { NVIC_InitTypeDef NVIC_InitStructure; #ifdef VECT_TAB_RAM /* Set the Vector Table base location at 0x20000000 */ NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0); #else /* VECT_TAB_FLASH */ /* Set the Vector Table base location at 0x08000000 */ NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0); #endif /* Setting the priority grouping bits length */ NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); /* Enable the DMA global Interrupt */ NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel1_IRQChannel; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); }2011-05-17 04:01 AM
Hello. Im going to try it now and notify you many thanks Johann
2011-05-17 04:01 AM
Hello. Thanks for the code. Unluckily the DMA did not occur in mine. Please, was the ADC1_DR_Address set as ((u32)0x40012444C)?. Please how was ADCConvertedValue decalred? Thanks Johann
2011-05-17 04:01 AM
First I'm M3allem and not Johann :);
Sorry I missed some declaration in my code: #define ADC1_DR_Address ((u32)0x4001244C) #define NumberOfSample 50 u16 ADCConvertedValue[NumberOfSample]; B.R. M3allem