1
\$\begingroup\$

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.

asked Jan 2, 2015 at 4:54
\$\endgroup\$
6
  • \$\begingroup\$ Clear ADFM bit in ADCON1 register to get high 8 bit of result in ADCRESH register after ADC conversion. \$\endgroup\$ Commented 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\$ Commented 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\$ Commented 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\$ Commented 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\$ Commented Jan 3, 2015 at 23:50

2 Answers 2

2
\$\begingroup\$

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.

answered Jan 2, 2015 at 5:25
\$\endgroup\$
2
\$\begingroup\$

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?)

answered Jan 2, 2015 at 12:09
\$\endgroup\$
1
  • 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\$ Commented Jan 2, 2015 at 17:14

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.