Hi~all,thank you for taking time to read my post,my trouble is about "The PIC16F690 occurs error in the AD changing ".
The following is a part of the wrong program:
INTCON=0XC0;//??????
TMR1IE=1;//????
TMR1L=(65536-2000)%256;//?????????
TMR1H=(65536-2000)/256;//?????????
T1CON=0X01;//??????????2ms????
g=getad1();//????
r=getad();//????
while((r>80&&r<180)&&(g>4&&g<89))
{
g=getad1();//????
r=getad();//????
}
PORTB=0;
}
void reset()
{
OSCCON=0x61; //????4M ????????
TRISA=0XFF; //A????????
TRISB=0X30; //RB6\RB7???????RB4\RB5?AD??????B??????4??????
TRISC=0; //C??RC4\RC5\RC6\RC7??????????????
PORTB=0;//???????????????????????
ADRESH=0; //AD????????
ADRESL=0; //AD????????
ANSELH=0X0C;//AN10?AN11?????xxxx1111?XXXX AN11\AN10\AN9\AN8
}
/**?????**/
void delay(uint x)
{
uint a,b;
for(a=x;a>0;a--)
for(b=108;b>0;b--);
}
/**?????**/
void delayus(uint x ,uchar y)
{
uint i;
uchar j;
for(i=x;i>0;i--);
for(j=y;j>0;j--);
}
uchar getad1()//????????
{
uchar adval;
ADCON1=0X10;//ADCON1=0X10;//??fosc/8 //ADCON1=0X50;fosc/16??????
ADCON0=0X29;//??AN10 ADCON0=0X29;??AN11 ADCON0=0X2D;??????
delay(1);//????????
GO=1;//????
while(GO);//???????
adval=ADRESH;//??????
ADON=0;//??AD???
return(adval);
}
uchar getad()//????????
{
uchar adval;
ADCON1=0X10;//ADCON1=0X10;//??fosc/8 //ADCON1=0X50;fosc/16
ADCON0=0X2D;//??AN10 ADCON0=0X29;??AN11 ADCON0=0X2D;
delay(1);//????????
GO=1;//????
while(GO);//???????
adval=ADRESH;//??????
ADON=0;//??AD???
return(adval);
}
void interrupt kk()//????
{
T1IF=0;//????????
TMR1L=(65536-2000)%256;//????2ms
TMR1H=(65536-2000)/256;
PORTC=~PORTC;//??????
The phenomenon is if I use my own two AD changing program,the output level of PORTB will change when PORTB = 0X40. AD changing will influence other pins? The open circuit and short circuit is normal ,and PORTB changed even it didn’t trigger protection. In another situation,when I isolate the AD changing in order to realizing the function,and the using also will be changed while PORTB is changing. Can you help me?
Thank you in advance!