I am trying to do something quite basic in that I have eight toggle switches connected to PORTB and eight connected to PORTC of an 18f452 microcontroller. I then have eight LED's on PORTD.
I can run some simple code to add PORTB and PORTC together and show the Answer on PORTD:
Code: Select all
Sub DoAddition()
PORTD = PORTB + PORTC ' add the two eight bit words together
End Sub
However when I try to OR the ports or AND the ports to display the result on PORTD (the LED's) nothing happens on the output I.E. the LED's don't light up no matter what I input on the switches.
Here's the code for ANDing the ports:
Code: Select all
Sub DoAND()
PORTD = PORTB AND PORTC ' and the two eight bit words together
End Sub
Code: Select all
Sub DoAND()
PORTBBuffer = PORTB
PORTCBuffer = PORTC
PORTD = PORTBBuffer AND PORTCBuffer ' and the two eight bit words together
End Sub
Thankyou in advance.