I have a PIC16f1824, which has a 10bit built-in ADC, but I only want 8 bit precision. I don't just want an 8 bit value, but actual 8 bit conversion i.e. higher samples per second at the cost of bits. Here I am stuck because the ADRESH register get loaded only once whole 10 bit conversion is performed.
-
\$\begingroup\$ Clear ADFM bit in ADCON1 register to get high 8 bit of result in ADCRESH register after ADC conversion. \$\endgroup\$GJ.– GJ.2015年01月02日 17:14:35 +00:00Commented Jan 2, 2015 at 17:14
-
\$\begingroup\$ You are asking an XY question. It would be better to specify your requirements in terms of required precision and required sample rate. \$\endgroup\$Clifford– Clifford2015年01月03日 03:35:33 +00:00Commented Jan 3, 2015 at 3:35
-
1\$\begingroup\$ The data sheet for the part is clear that a conversion is fixed at 11.5 Tad periods. It cannot be improved by reducing resolution on this particular part. As such it is a hardware issue not a programming question. \$\endgroup\$Clifford– Clifford2015年01月03日 03:45:12 +00:00Commented Jan 3, 2015 at 3:45
-
1\$\begingroup\$ You are asking the A/D to do something it was not designed to do. Read the datasheet. It's quite clear about what the A/D can do, and how to make it do it. If you need faster sampling than the built-in A/D can do, then you need to use a different A/D. Some of the PIC 24 and dsPICs can sample at a MHz or more. Keep in mind that a small 8 bit part like what you are using can only process samples so fast, regardless of how fast you can make the A/D generate them. What speed at 8 bits do you need? \$\endgroup\$Olin Lathrop– Olin Lathrop2015年01月03日 14:48:10 +00:00Commented Jan 3, 2015 at 14:48
-
\$\begingroup\$ Except the data sheet is also quite clear you can terminate a conversion early and receive the partially converted result, for this specific PIC at least. \$\endgroup\$Simon Jenkins– Simon Jenkins2015年01月03日 23:50:21 +00:00Commented Jan 3, 2015 at 23:50
2 Answers 2
This thread: http://www.edaboard.com/thread155430.html should help. Basically, you'll have to do some converting on your own, but configuring the ADC to left justify will give you bits 9-2 in the ADRESH byte, which you can then use as your 8-bit value.
I don't think you can configure the chip to give you 8-bit precision at the cost of higher samples/sec. That's a design design made when you order the part. I could be wrong though and I would consult with the appropriate data sheet.
There is no way in hardware to configure the ADC to perform 8 bit conversions.
A conversion can be terminated early however by clearing the GO/DONE bit in software. When this is done the partially complete result is placed in ADRESH/ADRESL (with the remaining bits matching the last bit that was converted).
So you could possibly perform 8 bit conversions by arranging, in software, to be clearing GO/DONE just after the 8th bit has been converted. (Maybe in a timer interrupt that's running at just the right rate, i.e. 2 * TAD faster than the full conversion would have taken?)
-
2\$\begingroup\$ Some PICs only load the ADRESH/ADRESL on complete 10 bit conversion and, if the conversion is terminated early, ADRESH/ADRESL remain unchanged. A little while back, I had looked into doing this myself with another PIC and had hit a brick wall. \$\endgroup\$Mathieu L.– Mathieu L.2015年01月02日 17:14:05 +00:00Commented Jan 2, 2015 at 17:14
Explore related questions
See similar questions with these tags.