ADC sampling Frequency

Stranet
Hi,
I'm trying to develop an application like a little oscilloscope with the
Mini2440 board and WIN CE 5.0

I've readed on the datasheet that the ADC can sample 500Khz I need only
50Khz... but with WInCE 5 I can't read the ADC value with less than 300uS
so I can achieve less then 3Khz.

Do you know how to do?

Thnx a lot.

davef
Can you find what the ADCCON register and the PRSCVL bits [13:6] are set to
by WinCe 5?   Maybe it is set to some "slow" default value.  See page 16-5
in the S3C2440.pdf file.

Note: comment about PCLK on the PRSCVL line page 16-5

Another comment about GCLK on top of page 16-3.  Did a search to find out
GCLK is and you only find it on pages 16-3, 16-4 and 16-7  I think GCLK is
the same as PCLK.

Looking at Figure 7-1 suggests that there might control registers that need
tweaking to determine the final conversion rate.

Good luck!

Stranet
Hi daver,
I don't know how to calculate the PCLK on my board.

I've setted the prescaler at various values... but it seems not to change
the result.

if you have some suggestion please send it! :)

Thxn a lot
Stranet

domodom
Is your application written in c++ ?

Stranet
Hi domdom,
no, my application is written in C# language.

But I've used pointers so the code is faster than OpenNetCF.dll code.

//------------------------------
static PhysicalAddressPointer iADCCON = new
PhysicalAddressPointer(0x58000000, 0x1);

static PhysicalAddressPointer iADCDAT0 = new
PhysicalAddressPointer(0x5800000C, 0x1);

static PhysicalAddressPointer iADCDAT1 = new
PhysicalAddressPointer(0x58000010, 0x1);  
    
unsafe public uint *PADC_CON;
unsafe public uint *PADC_DAT0;

PADC_CON = (uint*) iADCCON.GetUnsafePointer();
PADC_DAT0 = (uint*) iADCDAT0.GetUnsafePointer();
//------------------------------

The conversion works well but I can't achieve a conversion time less than
300uS

domodom
PCLK = 50MHz on my board with Wince6 image.

I don't have your source code, then it's difficult to help you, but if you
comment in your source code the line that starts the conversion, you should
be able to have an application that read the result of the last conversion
at the best speed possible. You then will be able to say if your problem is
in the processor or in your application...

domodom

Stranet
Hi Domodom,
I don't understand...
I have to comment the line where the start bit is setted?
I don't know if the ADC will works is this mode.

*stranet*

domodom
No, it won't works, you will always have the same value. But you should be
able able to know if it's the conversion that is slow (then your
application should run a lot faster) or if it's the application that is
slow (in this cas, the application will run at the same speed)
domodom

Stranet
Hi domodom,
If I run the same cicle in my application without "waiting" the ADC
conversion flag (Bit 15 ADCCON) the code is faster... so I think that the
problem is the ADC conversion time.

I've setted the prescaler value but It seems like nothing changes.

I'm starting to think that the TouchScreen driver (that use the ADC) reset
the prescaler always at the same value.

what you think about it?

*stranet*

domodom
Yes, it is possible, I didn't read the source code of the touch screen, but
it uses the same ADC...

Stranet
Hi Domodom,
have you understanded how to disable TouchScreen ADC conversion?

I've readed the datasheet but I don't understand how to set the ADC
Register to disable touchscreen.

*stranet*

domodom
No, I didn't have a look on it... Do you use the "Normal Conversion Mode"
mode without interrupt ? (to be able to make a conversion without beeing
seen by the touch panel driver ?)

Stranet
I tried to disable the touch screen directly in the register and the ADC
conversion time is improved.

You know how to set the delay register (ADCDLY)?
(see the datasheet)

*stranet*

domodom
Hello Stranet, 

I'm sorry, I'm not sure to understand your question.

There is only one ADC in the s3c2440 but several analog input. When you
want to make an analog conversion, the ADC must be switched on the analog
input. After the switch, the signal needs time to be ok to be converted
(the ADC is made with capacitors that take time to be charged). 
If you choose a delay too short, you will have a very bad precision, if you
choose a long delay, you will have a good precision.

The better for you is to make some tests to choose the better value for
your application.

If you don't use the touch panel and you make conversions of only one
input, you can choose a very short value... (because you don't have anymore
the problem of analog switch)

Is it the answer you were waiting for ?

Domodom

Stranet
Yes... but more exactly...
what the values mean?

I mean if I set ADCDLY = 1000 how many delay (for example in uS) I've
setted?

thnx for the help

*stranet*

davef
Manual:

ADCDLY

1) Normal Conversion Mode, XY position mode, auto position
mode. ® ADC conversion start delay value.
2) Waiting for Interrupt Mode.
When stylus down occurs at SLEEP MODE, generates Wake-Up
signal, having interval (several ms), for exiting SLEEP MODE.
Note: Don’t use Zero value (0x0000)
***

I get the impression that this delay is not the time between conversions.

PRSCVL page 16-5 

A/D converter prescaler value
Data value: 0 ~ 255
NOTE: ADC Freqeuncy should be set less than PCLK by
5times. (Ex. PCLK=10MHZ, ADC Freq.< 2MHz)

looks like this sets the interval between conversions.

domodom
Yes, it is possible.
In this case, the ADCDLY is the delay before to start the ADC.
The PRSCVL value is the time of the conversion.

What I don't understand is what stop the ADC ? Is it the end of a
conversion ? (in this case, the conversion rate determined from the PRSCVL
value would just be theorical ?) Or is it when you halt the ADC (bit
ADCCON[2]) ?
I think you have to make some tests to understand by youself...

domodom

davef
domodom,

My understanding:

Initialisation:
PRSCEN depending on clock frequency and/or the amount you want to prescale
by this bit needs to be one
PRSCVL the prescale or divide ratio you want

then you start the ADC by enabling the ADCCON[0] bit.

the read takes place and at the end of the conversion period (as defined
above) the conversion stops and the ECFLG is set to one.  If you want you
to test for the end of conversion you can look at this flag.

Looks like you can also start the ADC by reading the ADCCON register (not
sure where one would do this).

So, just enable the ADCCON[0] bit by making it one
and sit in a while loop until ECFLG = 1

while(ADCCON & (1<<ECFLG));
 
This is a blocking ADC conversion.

Otherwise, you just need to poll this flag and when it is 1 then read out
the stored adc value in ADCDAT0

Or, you may want to look at using an ADC interrupt.

Dave

Mohammad
Hi all
I need a sample source code in C# for reading ADC channels in Wince 5 .
If any body can help me please send me an email or a link for download
sample code.

Thanks for your helps.

Farzad
Hi All;

You can Improve The speed of ADC by Seting ADCDLY Register to 0

Best Regards

Vikram Tamboli
what is the final conclusion how we can improve the ADC conversion as i
want to read 4096 samples per second. is this possible?

Sam
I just got the sample rate 397kSPS. The key is that the ADCDLY needs to be
set to a very small value for example 1. The datasheet says "don't set it
to 0" so 1 is the good number.

My settings are:

FIN = 12MHz   //it's the TCXO frequency
FCLK = 405MHz
HCLK = FCLK/4 = 
PCLK = HCLK/2 = 50.625MHz
ADC prescaler = 23

So ADC clock is PCLK/(ADC prescaler+1) = 2.109375MHz
And it takes 5 ADC clock cycles to finish the ADC conversion. As a result
the ADC conversion rate can be as high as ADC clock/5 = 421.875kSPS. I used
wait and read approach so my sample rate is 397kSPS which is a little bit
less.

To verify it, I used the PWM timer to count the time needed for the ADC to
sample 400 samples.

Vikram
Could you please share your piece of code?