16F887 and ANSEL

General discussion on mikroPascal.
Post Reply
Author
Message
JimKueneman
Posts: 417
Joined: 10 Jan 2009 22:03

16F887 and ANSEL

#1 Post by JimKueneman » 10 Jan 2009 22:06

Code: Select all

  ANSEL       :=    0;                    // Set AN pins to Digital I/O
  ANSELH      :=    0;
 
I just started playing with mikroPascal and I have seen this in the demos and some sample code here. What does this do? I don't see in the Microchip datasheet where there is anything at the address ANSEL is mapped to or reference to that register name.

Thanks,
Jim

rmteo
Posts: 1330
Joined: 19 Oct 2006 17:46
Location: Colorado, USA

#2 Post by rmteo » 10 Jan 2009 22:38

From the datasheet of the PIC16F887:
3.2.1 ANSEL REGISTER
The ANSEL register (Register 3-3) is used to configure
the Input mode of an I/O pin to analog. Setting the
appropriate ANSEL bit high will cause all digital reads
on the pin to be read as ‘0’ and allow analog functions
on the pin to operate correctly.
The state of the ANSEL bits has no affect on digital output
functions. A pin with TRIS clear and ANSEL set will
still operate as a digital output, but the Input mode will
be analog. This can cause unexpected behavior when
executing read-modify-write instructions on the
affected port.

3.4.1 ANSELH REGISTER
The ANSELH register (Register 3-4) is used to
configure the Input mode of an I/O pin to analog.
Setting the appropriate ANSELH bit high will cause all
digital reads on the pin to be read as ‘0’ and allow
analog functions on the pin to operate correctly.
The state of the ANSELH bits has no affect on digital
output functions. A pin with TRIS clear and ANSELH
set will still operate as a digital output, but the Input
mode will be analog. This can cause unexpected
behavior when executing
Why pay for overpriced toys when you can have
professional grade tools for FREE!!! :D :D :D

JimKueneman
Posts: 417
Joined: 10 Jan 2009 22:03

#3 Post by JimKueneman » 27 Jan 2009 00:41

Yea, I am an idiot. I was not even looking at the right data sheet.

Jim

Post Reply

Return to “mikroPascal General”