打印

请教PORTA口问题

[复制链接]
3473|5
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
jerrylo|  楼主 | 2007-4-27 21:35 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
我使用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;
麻烦各位了!谢谢!
沙发
xieyuanbin| | 2007-4-29 14:35 | 只看该作者

是你电路问题。

有没有算过IO口的输出电流值?

使用特权

评论回复
板凳
yewuyi| | 2007-4-30 08:32 | 只看该作者

默认是AD口,你要转换成IO口……

使用特权

评论回复
地板
jiaqisun| | 2007-4-30 09:08 | 只看该作者

楼上正解!

使用特权

评论回复
5
jinling14| | 2007-5-1 01:10 | 只看该作者

怎么才能转换成I/O口呀?

初学PIC,还请指教

使用特权

评论回复
6
xieyuanbin| | 2007-5-2 17:40 | 只看该作者

未想那么简单

你的问题,数据手册上有详细解释.

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

主题

1

帖子

1

粉丝