Hi once again all.
I have a medium length program, with everything working....except for a couple of lines .....
What I have is a BINARY coded switch feeding 4 bits into portD lower 4 bits. The inputs have pull-down resistors and the switch switches 5v into the inputs.
The code is like this...
BLAH
BLAH
BLAH chip setup and first part working fine.
included in the above:
TRISD = %00001111 'low 4 bits inputs, high 4 bits unused
LOOP:
PORTB = PORTD
goto loop
after I read the inputs, go on to more code, which works OK
BLAH
BLAH
BLAH
Now, there are LEDs on PORTB to repeat the settings on the input port.
To my way of thinking, the inputs will be repeated on the LEDs and going to the loop will continually update the LEDs to match the inputs. IE, changing the switch position should be immediately repeated on the LEDs. (I have checked the PORTD input lines and they do change with the switch changes)
BUT.....the only way I can get the LEDs to update is to reset the PIC and then the current switch setting comes up on the LEDs correctly. I am using a 16F877 and have in fact swapped chips 3 times with the same results each time.
I have also added TOGGLE PORTC.0 , as a debug indicator, to just before the GOTO LOOP line and this output does in fact toggle, showing that the loop is looping correctly.
The 3 line of code were originally to read the input switch settings, calculate a delay and a few other things. The 3 lines shown above are a result of simplifying the final code back to absolute basics because the original code wasn't working either and was taken simpler to try and see what the trouble was, but that didn't show anything. It seems to me that the 3 lines above can't get much simpler and should work OK.
Bookmarks