PIC16f1937 IO口配置

发布者:MysticalSoul最新更新时间:2016-09-22 来源: eefocus关键字:PIC16f1937  IO口配置 手机看文章 扫描二维码
随时随地手机看文章
配置pic161937为数字输入的时候,首先要初使化ANSELx ,否则读为0.  

         // Register: ANSELA
volatile unsigned char           ANSELA              @ 0x18C;
// bit and bitfield definitions
volatile bit ANSA0               @ ((unsigned)&ANSELA*8)+0;
volatile bit ANSA1               @ ((unsigned)&ANSELA*8)+1;
volatile bit ANSA2               @ ((unsigned)&ANSELA*8)+2;
volatile bit ANSA3               @ ((unsigned)&ANSELA*8)+3;
volatile bit ANSA4               @ ((unsigned)&ANSELA*8)+4;
volatile bit ANSA5               @ ((unsigned)&ANSELA*8)+5;
#ifndef _LIB_BUILD
union {
    struct {
        volatile unsigned ANSA0               : 1;
        volatile unsigned ANSA1               : 1;
        volatile unsigned ANSA2               : 1;
        volatile unsigned ANSA3               : 1;
        volatile unsigned ANSA4               : 1;
        volatile unsigned ANSA5               : 1;
        volatile unsigned                     : 1;
        volatile unsigned : 1;
    };
    struct {
        volatile unsigned ANSELA              : 6;
    };
} ANSELAbits @ 0x18C;
#endif

// Register: ANSELB
volatile unsigned char           ANSELB              @ 0x18D;
// bit and bitfield definitions
volatile bit ANSB0               @ ((unsigned)&ANSELB*8)+0;
volatile bit ANSB1               @ ((unsigned)&ANSELB*8)+1;
volatile bit ANSB2               @ ((unsigned)&ANSELB*8)+2;
volatile bit ANSB3               @ ((unsigned)&ANSELB*8)+3;
volatile bit ANSB4               @ ((unsigned)&ANSELB*8)+4;
volatile bit ANSB5               @ ((unsigned)&ANSELB*8)+5;
#ifndef _LIB_BUILD
union {
    struct {
        volatile unsigned ANSB0               : 1;
        volatile unsigned ANSB1               : 1;
        volatile unsigned ANSB2               : 1;
        volatile unsigned ANSB3               : 1;
        volatile unsigned ANSB4               : 1;
        volatile unsigned ANSB5               : 1;
        volatile unsigned                     : 2;
    };
    struct {
        volatile unsigned ANSELB              : 6;
    };
} ANSELBbits @ 0x18D;
#endif

// Register: ANSELD
volatile unsigned char           ANSELD              @ 0x18F;
// bit and bitfield definitions
volatile bit ANSD0               @ ((unsigned)&ANSELD*8)+0;
volatile bit ANSD1               @ ((unsigned)&ANSELD*8)+1;
volatile bit ANSD2               @ ((unsigned)&ANSELD*8)+2;
volatile bit ANSD3               @ ((unsigned)&ANSELD*8)+3;
volatile bit ANSD4               @ ((unsigned)&ANSELD*8)+4;
volatile bit ANSD5               @ ((unsigned)&ANSELD*8)+5;
volatile bit ANSD6               @ ((unsigned)&ANSELD*8)+6;
volatile bit ANSD7               @ ((unsigned)&ANSELD*8)+7;
#ifndef _LIB_BUILD
union {
    struct {
        volatile unsigned ANSD0               : 1;
        volatile unsigned ANSD1               : 1;
        volatile unsigned ANSD2               : 1;
        volatile unsigned ANSD3               : 1;
        volatile unsigned ANSD4               : 1;
        volatile unsigned ANSD5               : 1;
        volatile unsigned ANSD6               : 1;
        volatile unsigned ANSD7               : 1;
    };
} ANSELDbits @ 0x18F;
#endif

// Register: ANSELE
volatile unsigned char           ANSELE              @ 0x190;
// bit and bitfield definitions
volatile bit ANSE0               @ ((unsigned)&ANSELE*8)+0;
volatile bit ANSE1               @ ((unsigned)&ANSELE*8)+1;
volatile bit ANSE2               @ ((unsigned)&ANSELE*8)+2;
#ifndef _LIB_BUILD
union {
    struct {
        volatile unsigned ANSE0               : 1;
        volatile unsigned ANSE1               : 1;
        volatile unsigned ANSE2               : 1;
        volatile unsigned                     : 5;
    };
    struct {
        volatile unsigned ANSELE              : 3;
    };
} ANSELEbits @ 0x190;
#endif
// bit and bitfield definitions

关键字:PIC16f1937  IO口配置 引用地址:PIC16f1937 IO口配置

上一篇:基于单片机的超声波测距报警系统设计
下一篇:pic16f1937 标准PWM

推荐阅读最新更新时间:2024-03-16 15:11

STM32的GPIO口的8种配置模式
一、 STM32的输入输出管脚有下面8种(4输入+2输出+2复用输出)可能的配置: ① 浮空输入_IN_FLOATING ② 带上拉输入_IPU ③ 带下拉输入_IPD ④ 模拟输入_AIN ⑤ 开漏输出_OUT_OD ⑥ 推挽输出_OUT_PP ⑦ 复用功能的推挽输出_AF_PP ⑧ 复用功能的开漏输出_AF_OD 1.1 I/O口的输出模式下,有3种输出速度可选(2MHz、10MHz和50MHz),这个速度是指I/O口驱动电路的响应速度而不是输出信号的速度,输出信号的速度与程
[单片机]
小广播
添点儿料...
无论热点新闻、行业分析、技术干货……
设计资源 培训 开发板 精华推荐

最新单片机文章
何立民专栏 单片机及嵌入式宝典

北京航空航天大学教授,20余年来致力于单片机与嵌入式系统推广工作。

换一换 更多 相关热搜器件
随便看看
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved