2006-07-24 05:45 AM
2006-03-19 12:22 PM
I am using STR710 ADC12.The program as below:
ADC12_ChannelSelect(ADC12_CHANNEL0); /* Start the Converter */ ADC12_ConversionStart(); /* Wait until the availabiliy of data in the specific flags */ while (ADC12_FlagStatus (ADC12_DA0)==RESET); /* Get the conversion result from the correponding Data register */ ADC_Reg = ADC12_ConversionValue(ADC12_CHANNEL0); But the program can't run out of : while (ADC12_FlagStatus (ADC12_DA0)==RESET);2006-03-22 12:24 PM
Yes! The problem is still the same.
It can't run out of : while (ADC12_FlagStatus (ADC12_DA0)==RESET);2006-03-26 07:54 PM
Hi,
Just a suggestion: did you set the ADC_en bit in the PCU_BOOTCR register? If not the ADC will not run and the sample ready flag not set. Regards, Jimmey2006-07-19 12:05 AM
Hi Dom
Did you solve the ADC12 problem? If so please let me know what was wrong, as I am getting the same problem - not every time though, which makes it even more scary ;-). Cheers Gawie2006-07-20 08:46 PM
Hi
I solve my problem, but I am not quite sure of my solution. Maybe somebody can shed some light on the issue. On startup I did initialise the ADC by calling the following functions: // Configure the used analog input to HI_AIN GPIO_Config (GPIO1, 0x0001, GPIO_HI_AIN_TRI); // Initialize the conveter register. ADC12_Init(); // Configure the ADC prescaler to have a sampling frequency = 500Hz ADC12_PrescalerConfig(500); // Select the conversion mode=single channel ADC12_ModeConfig (ADC12_SINGLE); And when ever I want to get an ADC value I did a few (100 or so) conversions and then calculated the average. I called the functions as follow: // Select the channel to be converted ADC12_ChannelSelect(ADC12_CHANNEL0); // Start the Converter ADC12_ConversionStart(); // Wait until the availabiliy of data in the specific flags while (!ADC12_FlagStatus (ADC12_DA0)); // Get the conversion result from the corresponding Data register ADC_Reg = ADC12_ConversionValue(ADC12_CHANNEL0); My problem was that the flag, indicating that the conversion was completed, was not set on some occasions. I fixed it by doing the init routines not just at startup, but also every time I wanted to do an ADC conversion. Does this make sense and do I have to init the ADC before every conversion? Any comment would help ;-). Thanks, Gawie2006-07-21 04:01 AM
Hello,
Normally you don't need to initialize the ADC before every conversion, please could you tell me wich library version you are using and check the ADC12_Init(); funtion body . cheers, Hich2006-07-21 09:11 AM
Hi
I am using libary ver 3.1 and the ADC12_Init() looks like follows: void ADC12_Init(void) { /* Initiate ADC12 registers to their reset values */ ADC12->CSR = 0x0000; ADC12->CPR = 0x0005; } Cheers Gawie2006-07-24 05:45 AM
Ok, I solved my problem!
I had more than one channel selected in ADC12->CSR while I was using the ADC in single conversion mode and that was the cause why the completion flag was never set. Cheers Gawie