欢迎访问ic37.com |
会员登录 免费注册
发布采购

PIC16F886-I/SS 参数 Datasheet PDF下载

PIC16F886-I/SS图片预览
型号: PIC16F886-I/SS
PDF下载: 下载PDF文件 查看货源
内容描述: 28 /40/ 44引脚,增强基于闪存的8位CMOS微控制器采用纳瓦技术 [28/40/44-Pin, Enhanced Flash-Based 8-Bit CMOS Microcontrollers with nanoWatt Technology]
分类和应用: 闪存微控制器和处理器外围集成电路光电二极管时钟
文件页数/大小: 288 页 / 5120 K
品牌: MICROCHIP [ MICROCHIP ]
 浏览型号PIC16F886-I/SS的Datasheet PDF文件第45页浏览型号PIC16F886-I/SS的Datasheet PDF文件第46页浏览型号PIC16F886-I/SS的Datasheet PDF文件第47页浏览型号PIC16F886-I/SS的Datasheet PDF文件第48页浏览型号PIC16F886-I/SS的Datasheet PDF文件第50页浏览型号PIC16F886-I/SS的Datasheet PDF文件第51页浏览型号PIC16F886-I/SS的Datasheet PDF文件第52页浏览型号PIC16F886-I/SS的Datasheet PDF文件第53页  
PIC16F882/883/884/886/887  
3.4.1  
ANSELH REGISTER  
3.3  
PORTB and TRISB Registers  
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.  
PORTB is an 8-bit wide, bidirectional port. The  
corresponding data direction register is TRISB  
(Register 3-6). Setting a TRISB bit (= 1) will make the  
corresponding PORTB pin an input (i.e., put the  
corresponding output driver in a High-Impedance mode).  
Clearing a TRISB bit (= 0) will make the corresponding  
PORTB pin an output (i.e., enable the output driver and  
put the contents of the output latch on the selected pin).  
Example 3-3 shows how to initialize PORTB.  
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  
instructions on the affected port.  
when  
executing  
read-modify-write  
Reading the PORTB register (Register 3-5) reads the  
status of the pins, whereas writing to it will write to the  
PORT latch. All write operations are read-modify-write  
operations. Therefore, a write to a port implies that the  
port pins are read, this value is modified and then written  
to the PORT data latch.  
3.4.2  
WEAK PULL-UPS  
Each of the PORTB pins has an individually configurable  
internal weak pull-up. Control bits WPUB<7:0> enable or  
disable each pull-up (see Register 3-7). Each weak  
pull-up is automatically turned off when the port pin is  
configured as an output. All pull-ups are disabled on a  
Power-on Reset by the RBPU bit of the OPTION register.  
The TRISB register (Register 3-6) controls the PORTB  
pin output drivers, even when they are being used as  
analog inputs. The user should ensure the bits in the  
TRISB register are maintained set when using them as  
analog inputs. I/O pins configured as analog input always  
read ‘0’. Example 3-3 shows how to initialize PORTB.  
3.4.3  
INTERRUPT-ON-CHANGE  
All of the PORTB pins are individually configurable as an  
interrupt-on-change pin. Control bits IOCB<7:0> enable  
or disable the interrupt function for each pin. Refer to  
Register 3-8. The interrupt-on-change feature is  
disabled on a Power-on Reset.  
EXAMPLE 3-3:  
INITIALIZING PORTB  
BANKSELPORTB  
;
CLRF  
PORTB  
;Init PORTB  
;
BANKSELTRISB  
For enabled interrupt-on-change pins, the present value  
is compared with the old value latched on the last read  
of PORTB to determine which bits have changed or  
mismatched the old value. The ‘mismatch’ outputs of  
the last read are OR’d together to set the PORTB  
Change Interrupt flag bit (RBIF) in the INTCON register.  
MOVLW  
MOVWF  
B‘11110000;Set RB<7:4> as inputs  
;and RB<3:0> as outputs  
TRISB  
;
Note:  
The ANSELH register must be initialized  
to configure an analog channel as a digital  
input. Pins configured as analog inputs will  
read ‘0’.  
This interrupt can wake the device from Sleep. The user,  
in the Interrupt Service Routine, clears the interrupt by:  
a) Any read or write of PORTB. This will end the  
mismatch condition.  
b) Clear the flag bit RBIF.  
3.4  
Additional PORTB Pin Functions  
A mismatch condition will continue to set flag bit RBIF.  
Reading or writing PORTB will end the mismatch  
condition and allow flag bit RBIF to be cleared. The latch  
holding the last read value is not affected by a MCLR nor  
Brown-out Reset. After these Resets, the RBIF flag will  
continue to be set if a mismatch is present.  
PORTB pins RB<7:0> on the device family device have  
an interrupt-on-change option and a weak pull-up  
option. The following three sections describe these  
PORTB pin functions.  
Every PORTB pin on this device family has an  
interrupt-on-change option and a weak pull-up option.  
Note:  
If a change on the I/O pin should occur when  
the read operation is being executed (start of  
the Q2 cycle), then the RBIF interrupt flag  
may not get set. Furthermore, since a read  
or write on a port affects all bits of that port,  
care must be taken when using multiple pins  
in Interrupt-on-Change mode. Changes on  
one pin may not be seen while servicing  
changes on another pin.  
© 2007 Microchip Technology Inc.  
Preliminary  
DS41291D-page 47  
 复制成功!