新聞中心

PIC16f1937 IO口配置

作者: 時(shí)間:2016-11-18 來源:網(wǎng)絡(luò) 收藏
配置pic161937為數(shù)字輸入的時(shí)候,首先要初使化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

本文引用地址:http://butianyuan.cn/article/201611/315603.htm

// 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



關(guān)鍵詞: PIC16f1937IO口配

評論


技術(shù)專區(qū)

關(guān)閉