When to use ADCON1 in c programming on the pic18f8722

Click For Summary
SUMMARY

ADCON1=0x0F is used in C programming on the PIC18F8722 microcontroller to configure PORTA pins as digital I/O by disabling the analog input mode. This setting is crucial when utilizing pushbuttons and switches, ensuring that all pins are treated as digital. The configuration of ADCON1 must be complemented by appropriate settings in the TRISA and LATA registers to achieve the desired functionality for mixed input/output configurations.

PREREQUISITES
  • Understanding of PIC18F8722 microcontroller architecture
  • Familiarity with ADCON1 register settings
  • Knowledge of TRISA and LATA register functionalities
  • Basic C programming skills for embedded systems
NEXT STEPS
  • Study the ADCON1 register configuration in detail from the PIC18F8722 datasheet
  • Learn about the TRISA and LATA registers for managing I/O pin directions
  • Explore examples of using pushbuttons with the PIC18F8722
  • Investigate the implications of analog vs. digital pin configurations in embedded systems
USEFUL FOR

Embedded systems developers, microcontroller programmers, and anyone working with the PIC18F8722 who needs to manage I/O configurations effectively.

fractal01
Messages
13
Reaction score
1
Under what circumstances would you use ADCON1=0x0F? All I know at the moment is for using the pushbuttons and using the switches and then I saw a piece of code using the pushbuttons without this line in it and I was wondering whether I was wrong all of this time. I have tried googling and looking in the c18 data booklet but I am having problems with my micro at the moment and can't try writing codes myself. Does anyone know?
 
Physics news on Phys.org
Many years since I programmed the PIC but..

ADCON1 is to do with the A-D converter on PORTA. Looks like setting ADCON1 to 0x0F disables the analog input mode for all pins making Port A digital I/O (even though it's probably already set to that mode on Reset).

http://ww1.microchip.com/downloads/en/devicedoc/39646c.pdf

ADCON1 = — — VCFG1 VCFG0 PCFG3 PCFG2 PCFG1 PCFG0

So 0F means

VCFG<1:0> = 00 => Controls the A-D voltage reference
PCFG<3:0> = 1111 => All pins are Digital I/O

See page 272.

In case it's not obvious.. It's not enough just to write to ADCON1. Port A is configured via the TRISA and LATA registers. All three need to be right on a bit by bit basis if you have some that are inputs, some outputs and some Analog Inputs.
 
Last edited:

Similar threads

  • · Replies 9 ·
Replies
9
Views
13K
Replies
1
Views
3K
Replies
7
Views
3K
  • · Replies 1 ·
Replies
1
Views
11K
  • · Replies 24 ·
Replies
24
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 21 ·
Replies
21
Views
4K
  • · Replies 7 ·
Replies
7
Views
2K