rovtech
Joined: 24 Sep 2006 Posts: 262
|
Setting up ADC ports and older PICs |
Posted: Mon Aug 25, 2014 12:49 pm |
|
|
I pass along the following as useful information. Always check the .h file if you have compile problems.
I used
Code: | setup_adc_ports(AN0_AN1_AN2_AN3_AN4); |
for a 16F874A and it works.
I tried
Code: | setup_adc_ports(AN0_AN1); |
for the 16F874A and it will not compile. What if I only want the two ADC inputs? Look for a newer PIC (16F884?)
I tried
Code: | setup_adc_ports(AN0_AN1_AN2_AN3_AN4); |
for a 16F722 and it does not compile. I must use
Code: | setup_adc_ports(sAN0|sAN1); |
which I got from the .h files and it works.
Why the _ and | and why the s before the ANx?
Answers from CCS: Older chips only allowed certain combinations of AN pins to be set to analog so we used the AN0_AN1_AN2_AN3_AN4 constants for each combination that was allowed. Newer chips allow any combination of pins so we used the OR bar method to specify the desired pins. The s was because many users by then used their own defines with ANx to identify the pins for other uses.
Me: If you stick with the same PIC for years check occasionally for a newer pin compatible replacement. The 16F722 is not that old and is I2C slave only but the newer 16F882 chip can be master as well. A 10 year old car is "old" but a 10 year old PIC is ancient. |
|