Chasing more bugs in hitec c!
Please, someone confirm whether this is 'correct' or not, it is sending me mad!
I was hoping to use RD6, as a pin for sending an ultrasound signal down.
However, it appears that changing RD7 is changing RD6....
I have two chips set up with the same circuit, and the same is happening on both.
When One_Wire_RS() is called, both RD6 and RD7 are changed. I couldn't work out going through the code why RD6 was changing, so I am changing RD5 manually, and watching RD5, RD6 and RD7,
I am watching what is happening with a logic analyser.
When One_Wire_RS() is called, RD6 is set low, as well as RD7 (and also RD5, I was using this to trace exactly which call it was which did it).
(doing a find in files for D6 shows only the ultrasound calls, TRIS is set only for the whole port at the beginning of the program. The LCD routines were portD, but I have moved them for debugging purposes to the end of the while loop, and are wrapped in USTX=1)
WHY is RD6 changing?
Please, someone confirm whether this is 'correct' or not, it is sending me mad!
I was hoping to use RD6, as a pin for sending an ultrasound signal down.
However, it appears that changing RD7 is changing RD6....
I have two chips set up with the same circuit, and the same is happening on both.
When One_Wire_RS() is called, both RD6 and RD7 are changed. I couldn't work out going through the code why RD6 was changing, so I am changing RD5 manually, and watching RD5, RD6 and RD7,
I am watching what is happening with a logic analyser.
When One_Wire_RS() is called, RD6 is set low, as well as RD7 (and also RD5, I was using this to trace exactly which call it was which did it).
(doing a find in files for D6 shows only the ultrasound calls, TRIS is set only for the whole port at the beginning of the program. The LCD routines were portD, but I have moved them for debugging purposes to the end of the while loop, and are wrapped in USTX=1)
WHY is RD6 changing?
Rich (BB code):
#define TPIN TRISD7
#define DPIN RD7
bit prescence = 0;
void One_Wire_High(){
DPIN=1;
TPIN=1;
}
void One_Wire_Low(){
TPIN=0;
DPIN=0;
}
bit Get_One_Wire_Bit(){
TPIN=0;
char a=DPIN;
TPIN=1;
return a;
}
bit One_Wire_RS(void){
One_Wire_High();
__delay_us(TG);
prescence = 0;
One_Wire_Low();
__delay_us(TH);
One_Wire_High();
__delay_us(TI);
if (Get_One_Wire_Bit() == 0 ){
prescence=1;
};
#define USTX RD6
#define USTXTRIS TRISD6
void main(void){
//initialise everything
USTXTRIS=0;
USTX=1;
TPIN=0; //output for 1wire
DPIN=1; // 1wire should be constantly high unless data is being sent
while(1){
sleep(); //Is woken up by SQWE output on pin RB0
//other routines run, RD6 is still high
TRISD5=0;
RD5=1; //watching LA, RD6 is still high, RD5 goes high
if(1 == One_Wire_RS()){ //I know something is there in this case anyway
TOK=1;
RD5=0;
USTXTRIS=0;
USTX=1;
}
}
}