Hello guys, I am newbie here. I would like to make a programme that take from 2 channels ADC and via DMA store them in an array and then shows flags HT and TC.Do u have any example? How can I set an input of 600 khz?
/* Enable ADC2 */ ADC_Cmd(ADC2, ENABLE);
/* Enable ADC2 reset calibration register */ ADC_ResetCalibration(ADC2); /* Check the end of ADC2 reset calibration register */ while(ADC_GetResetCalibrationStatus(ADC2));
/* Start ADC2 calibration */ ADC_StartCalibration(ADC2); /* Check the end of ADC2 calibration */ while(ADC_GetCalibrationStatus(ADC2));
/* Start ADC1 Software Conversion */ ADC_SoftwareStartConvCmd(ADC1, ENABLE);
/* Test on DMA1 channel1 transfer complete flag */ while(!DMA_GetFlagStatus(DMA1_FLAG_TC1)); /* Clear DMA1 channel1 transfer complete flag */ DMA_ClearFlag(DMA1_FLAG_TC1); while (1) /* Test on DMA1 channel1 transfer half flag */ while (!DMA_GetFlagStatus (DMA1_FLAG_HT1)); /* Clear DMA1 channel1 transfer half flag */ DMA_ClearFlag (DMA2_FLAG_HT1) ; while (1) { } }
/** * @brief Configures the different system clocks. * @param None * @retval None */ void RCC_Configuration(void) { /* ADCCLK = PCLK2/4 */ RCC_ADCCLKConfig(RCC_PCLK2_Div4); /* Enable peripheral clocks ------------------------------------------------*/ /* Enable DMA1 clock */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
/* Enable ADC1, ADC2 and GPIOC clock */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1 | RCC_APB2Periph_ADC2 | RCC_APB2Periph_GPIOC, ENABLE); }
/** * @brief Configures the different GPIO ports. * @param None * @retval None */ void GPIO_Configuration(void) { GPIO_InitTypeDef GPIO_InitStructure;
/* Configure PC.01, PC.02 and PC.04 (ADC Channel11, Channel12 and Channel14) as analog input ----------------------------------------------------------*/ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_4; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; GPIO_Init(GPIOC, &GPIO_InitStructure); }
#ifdef USE_FULL_ASSERT
/** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name * @param line: assert_param error line source number * @retval None */ void assert_failed(uint8_t* file, uint32_t line) { /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* Infinite loop */ while (1) { } }
#endif
/** * @} */
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
where I have added a HT flag still don't know if it is right. I should use an array of 200 for storing adc1 and adc2 from the respective channels c1 and c2 via dma. I will only debug in simulator,i don't have any board and micontroller yet. Please let me know if u want more specification about the project. Thanks a lot!