You have to configure PORTA as fully digital, otherwise, when you do a bsf PORTA,n the other pins get cleared for you. writing b'00000110' to ADCON1 (0x9Fh) will do this. The other option would be to have a shadow register for PORTA, and do the bsf / bcf on this, then move the whole register to the port at once. Hope this helps, Regards, Kevin ----- Original Message ----- From: "Glenn Paul Vendiola" To: Sent: Tuesday, May 22, 2001 6:10 AM Subject: [PIC]: Device I/O 3rd part > Hi, yup maybe it's better for me to discuss my application for a while > so that somebody can help me. > > First, used PortA pins are all outputs and used PortB pins are all inputs. > > > RB1, RB2, RB4, and RB5 receive the sensor inputs (high or low)which are > latched by a D-flipflop. > > RA0, RA1, RA2, RA3 are used to clear the D-flipflop of each sensor respectively. > > What the uController is doing is that it polls each sensor repeatedly > and compares it to a certain value then responds accordingly. > > For example... If RB1 sees 100 "gray" (a mixture of high and lows) values > without being reset, it will send a count signal. If RB1 sees 20 consecutive > "Low" values, the counter will reset the incrementor. > > This approach works well with only one channel being used. But when I > enable all 4 channels. I get something unexpected. It does not count > and the d-flipflop is reseted rapidly. > > I placed a variable "watcher" that has a value of the frequency of sensor > resets. I found that I needed to reset the sensor's d-flipflop every > 3 mainloops to have it working the way I wanted it to. If I take that > out, the D-flipflop will continue to be set even after the event of blocking > the light sensor is over. > > Please see the code that I've attached in my previous email. > > Thanks and hope this will do it. > > Glenn > > __________________________________________________ > FREE voicemail, email, and fax...all in one place. > Sign Up Now! http://www.onebox.com > > -- > http://www.piclist.com hint: PICList Posts must start with ONE topic: > [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads > > > -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads