At 10:51 AM 5/24/2006, Goran Hosinsky wrote: >I am trying to set selected bits in GPIO using >bsf GPIO, n where n can be 0,1,2,4 >The selected bit gets set ok but any bit which is >already on is cleared at the same time. Why is >this - and how should I do to set and clear bits >individually? >test code: bit 0 blinks once and then bit 1 is set: > > bsf GPIO,0 > call delay > bsf GPIO,1 >loop goto loop Hi there, Goran. I suspect that your problem is caused by the default setting in the CMCON register. The default power-up settings configure ports GPIO,0 and GPIO,1 as analog inputs. This means that they will always read as a logic 0 when read. Others have mentioned R-M-W problems and that is exactly what this is. However, the easy cure (assuming that you are using the internal RC oscillator at 4 MHz) is to simply load the value of 0x07 into register CMCON. Hope this helps. dwayne -- Dwayne Reid Trinity Electronics Systems Ltd Edmonton, AB, CANADA (780) 489-3199 voice (780) 487-6397 fax Celebrating 22 years of Engineering Innovation (1984 - 2006) .-. .-. .-. .-. .-. .-. .-. .-. .-. .- `-' `-' `-' `-' `-' `-' `-' `-' `-' Do NOT send unsolicited commercial email to this email address. This message neither grants consent to receive unsolicited commercial email nor is intended to solicit commercial email. -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist