On Monday, July 9, 2012, Peter wrote: > I have some code I wrote a long time ago and reactivated now. It has a > weird > RBPU problem. Description: > > The code is for 16F84A (no discussion on this please), it sets PORTB RB0 > and RB1 > as inputs, turns on _RBPU, and writes xxxxxx11 into PORTB. This is to tur= n > on > pullups and allow 2 tact switches to be read. This works, but later, whil= e > the > program runs, the xxxxxx11 becomes xxxxxx00 somehow. I am sure I am missi= ng > something but none of the simulators I used duplicate the problem. > > I don't think the 84a has a separate output latch. So writing pins on PORTB that are set to tristate has no effect. What is the voltage on RB0 and RB1 when PORTB reads 0 for those pins? > So, assuming that: > - PORTB is always in tris mode 00000011 > - OPTION _RBPU is set to 0 and never changed > - all writes to PORTB write 11 into RB0 RB1 > > WHAT can change the RB0 RB1 to 0s and turn off the pullups? > > The accesses to PORTB are of the following types: > > 1. ... > iorwf Fbflags,w ; temp register which has 11 in its lower bits, always, > checked > movwf PORTB > > 2. movf Fbflags,w ; as above > iorwf PORTB,f > > 3. movf PORTB,w ; pure read > andlw SW_MASK ... > > 4. bsf PORTB,SOMEBIT ; other than 0 or 1 > nop > bcf PORTB,SOMEBIT > > Which one of these is suspect of resetting the PORTB output bits RB0 and > RB1, do > you think? Also, none of the sims I have reproduce the PORTB written as > xxxxxx11 > correctly when its 0,1 pins are inputs. There should be a display for the > write > latch and another for the read latch, I think? > > tia, > > -- Peter > > > > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > --=20 Regards, Mark markrages@gmail --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .