I am working on a PIC18f4520. To do my test, I have connected a led to the pic. The following items are the steps I would like to do :
Save the value of the port set for the LED (which blinks according to the ISR subroutine I wrote, and can be look at in this case as a clock signal). For this I did :
unsigned char portValue; // initialization TRISBbits.TRISB5 = 0; // LED on RB5 set as output portValue = PORTBbits.RB5; // operation in the main while loop
Left shift the bits of portValue by one but with the insertion of the RB5 value. To illustrate :
--> if RB5 = 1, I would have portValue = 0b0000 0001 --> at t+1, RB5 = 0 then portValue = 0b0000 0010 --> at t+2, RB5 = 1 then portValue = 0b0000 0101 --> and so on (RB5 taking 1 or 0 and no other value)
With what I have wrote so far I can only do a left shifting. But I can't find a way to "add" the RB5...
Does something like
portValue = portValue<<(&PORTBbits.RB5);
could work ? Bit shifting operations are quite new to me so my questions can be odd.
Anyhow, thanks in advance !