您的位置 首页 观点

PIC16f1937 IO口装备

配置pic161937为数字输入的时候,首先要初使化ANSELx,否则读为0.//Register:ANSELAvolatileunsignedcharANSELA@0x18C;/…

装备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

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/news/guandian/266144.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部