0
votes

I am working on PIC16F887, and my task is mainly based on adc readings (8bit). There are 10 different analog inputs, so reading each of them one by one takes pretty long time. The clock is 20Mhz, the only allowed device frequency for adc is Fosc/32 (for 20mhz clock of course), which tesults in TAD=1.6us

The exact adc reading should take 10 TAD (due to 8bit reading), briefly 16us.

Here comes the question; What would happen if I use 10us for example. I want to have even smaller delays. I think ADC module of the PIC uses successive approximation. Does it mean the most significant bits are read first? I think accuracy of first 4 bits are enough for my calculations. But what will be the values of the remaining bits? will they be zero? or unidentified, might be any level?

Thanks in advance

1
"What would happen if I use 10us for example" - use 10us for what, specifically?Oliver Charlesworth
I've mistakeously used smaller delay in my project and as a result LEAST significant bits was read, while most significant stays unchanged at random (depending on device and connection scheme) levels. So i doubt smaller delays are a good idea.kipar

1 Answers

2
votes

Read the ADC section of the manual for the PIC16F887. Look for specific information on how to use the ADC ports. Generally, it is not necessary to use code that polls the ADC port as it runs. That is, you can activate an ADC port and the hardware will do the successive approximations and when complete the hardware will post a bit in a register that your program can reference.

This means that your code can multiplex multiple ADC ports and only worry about processing the data from the ADC when it has a sample ready for your code. At that point your considerations will be how efficient is your own code that uses the ADC data.

The same manual will tell you if you can interrupt an ADC to get the first four bits, etc. It will also tell you how to set the clocks for the ADC ports to different frequencies.

Finally, it is better that you read this for yourself. If you have a specific question then re-ask with a link to the manual, page number, and your specific concern.