I have a short program that simulates perfectly but in the real world it's doing one wrong thing. Again I'm working with the 16c65b and I have port A as output with a LEDs, and ports B and C are input ports. I'm only making actual use of the lower 4 bits of port C and all of port B, but all pins are pulled up so no inputs are floating. It's that same algorithm I had trouble with before with the goal being to take a ground wire and move it along port B and first 4 pins of port C, one at a time, and have an LED show in a blink if it's moving left or right along the pins. This is done with the 16 bit subtraction routine where the upper 4 port C bits are anded with 0000 to null out any readings that should take place on those ports, and the proper 16 bit input containing lower byte from port B and upper byte from port C anded 00001111, is sent to the subtract routine. The program simulates fine, if I toggle a port B or port C stimulus bit, the output shows left or right movement, and if I happen to stimulate one of the upper 4 bits of port C, the simulator ignores it and doesn't show any output indicaton because the reading was anded with 0 and not calculated in the subtract routine. But when I put the code into the chip and run it in the real world, it works fine except if I stimulate one of the upper 4 port C bits, it will actually activate one of the LEDs to show that motion occured. But it only does this once while I'm moving around those masked out bits. If I move back and forth between the upper 4 port C bits, only the first action will register on the LED and the rest are properly masked out and ignored, until I stimulate a proper input and then return to the masked out bits, again only the first one will register and the rest are then acting as they should, doing nothing. Based on observation, the fact that it is always the counter-clockwise LED indicator that responds to those maksed out illegal pins, this indicates that the program is seeing a negative number from those masked readings. It shouldn't be zero because the program is set up to ignore zero readings and just resample until it gets a stimulated pin. It isn't a positive number because that would cause the clockwise indicator to go off. How can this happen, the simulator shows that the program executes exactly as it was intended to, but the real world has a strange occurance like this. I'm thinking maybe this is even the problem I had before when trying to include port D as a second input channel along with the upper 4 bits of port C being attached to port D's bits. Here is what I am doing basically movfw PORTC andlw b'00001111' movwf Temp Then the math routine subtracts using the temp masked variable, so if there was a stimulated port C upper pin, it should be gone, no? I don't know why they're registering at all. It's safe to assume that there is nowhere that the port C reading is being manipulated after it is masked to accidently unmask etc....I'd think the simulator would have picked up such a bug anyway. What could be doing this? -- http://www.piclist.com hint: PICList Posts must start with ONE topic: "[PIC]:" PIC only "[EE]:" engineering "[OT]:" off topic "[AD]:" ad's