We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello all, I am working with a MCBSTR9 and I just don't seem to be able to get my ADC to get to work (polling). It keeps on giving 0. Here is the configuration proceudre:
static void ADC_Configuration(void) { SCU->GPIOIN[4] |= 0x01; /* P4.0 input - mode 0 */ SCU->GPIOOUT[4] &= 0xFFFC; /* P4.0 output - mode 0 */ GPIO4->DDR &= 0xFE; /* P4.0 direction - input */ SCU->GPIOANA |= 0x0001; /* P4.0 analog mode ON */ ADC_DeInit(); /* ADC Deinitialization */ /* ADC Structure Initialization */ ADC_StructInit(&ADC_InitStructure); /* Configure the ADC in continuous mode conversion */ ADC_InitStructure.ADC_Channel_0_Mode = ADC_NoThreshold_Conversion; ADC_InitStructure.ADC_Select_Channel = ADC_Channel_0; ADC_InitStructure.ADC_Scan_Mode = DISABLE; ADC_InitStructure.ADC_Conversion_Mode = ADC_Continuous_Mode; /* Enable the ADC */ ADC_Cmd(ENABLE); /* Prescaler config */ ADC_PrescalerConfig(15); /* Configure the ADC */ ADC_Init(&ADC_InitStructure); /* Start the conversion */ ADC_ConversionCmd(ADC_Conversion_Start); }
and the main loop:
// configure system clocks SCU_MCLKSourceConfig(SCU_MCLK_OSC) ; SCU_PLLFactorsConfig(192,25,2); /* PLL = 96 MHz */ SCU_PLLCmd(ENABLE); /* PLL Enabled */ SCU_MCLKSourceConfig(SCU_MCLK_PLL) ; /* MCLK = PLL */ // Set the PCLK Clock to MCLK/2 */ SCU_PCLKDivisorConfig(SCU_PCLK_Div1) ; SCU_APBPeriphClockConfig(__ADC, ENABLE); ADC_Configuration() ; while (1) { while(ADC_GetFlagStatus(ADC_FLAG_ECV) == RESET); /* Get the conversion value */ Conversion_Value = ADC_GetConversionValue(ADC_Channel_0); /* Clear the end of conversion flag */ ADC_ClearFlag(ADC_FLAG_ECV); }
as you can see I am working at 96MHz, so I need a prescalar 15 for the ADC. Any ideas?
Thanks in advance