我使用PIC16F883对IO口进行操作,我在PORTA送0x0f,怎么RA0,RA1,RA2,RA3的电压都只有1.6V呢? 请各位帮我诊断一下。初始化芯片程序如下: void InitChip() { STATUS = 0; CLRWDT(); // init interrupt module INTCON = 0; // disable all interrupt PIE1 = 0; // disable interrupt PIE2 = 0; PIR1 = 0; PIR2 = 0; RBIE = 0; // INTE = 0; INTE=0; // INT1IE=0; // INTCON2=0; // INTCON3=0; // init power control register PCON = 0x03; RBPU = 0; IOCB = 0; //enable port B pullups, prescaler to watchdog // init timer0 module,prescalar set to 1:32 // has done in OPTION_REG TMR0 = 0; T0CS =0; PSA = 0; PS2 = 1; PS1 = 0; PS0 = 0; // init TIMER1 module, // prescalar set to 1:8, turn off timer1 T1CON = 0x30; TMR1H = 0; TMR1L = 0; // init TIMER2 module, // postscaler set to 1:5,prescalar set to 1:1, turn off timer1 T2CON = 0X20; TMR2 = 0; PR2 = 150;
// init CCP module // disable ccp1 and ccp2 CCP1CON = 0x30; CCP2CON = 0; // CCP3CON = 0; // init ssp module // disable ssp SSPCON = 0; SSPCON2 = 0; SSPBUF = 0;
// init usart module SPBRG = 129; // 9600 baud rate TXSTA = 0x04; // 8 bit transmition, disable transmition RCSTA = 0x00; //disable usart receiver, 8 bit receive //init comparator register CM1CON0 = 0x03; CM2CON0 = 0x03; CM2CON1 = 0x00; VRCON = 0; SRCON = 0; //init comparator register PWM1CON = 0; //init ad module ADCON1 = 0x0f; // select RA0,RA1,RA3 as digital IO ADCON0 = 0; ANSEL = 0; ANSELH = 0; // ADCON2 = 0; } IO操作如下 TRISA = 0x10; PORTA = 0x0f; 麻烦各位了!谢谢!
|