I cant use like that because I am also going to use UART to the computer (which uses RC7 and RC6 as well). It might clear the UART values ??
If the simple LEDs doesn't function, I fear that the UART are also affected the same way.
The hardware UART takes over the pin functions and it doesn't get affected if you write to the port.
About the Shadow Register, I thought that I would retain the values of PORTC by putting it into a variable, then using bit-wise operation by changing which bit that i only want, then putting it back to the PORTC.(To solve RMW)
I think that you have understood "retaining the values of PORTC" incorrectly.
The shadow register retains the value that you want the port to be at, not the value that it was recently. In particular, it retains the value of 7 of the bits when you want to be concentrating on only one with a bitwise operation.
The RMW problem happens because many operations on PORTC read the voltages on the pins as bits, modify some of those, and write back to the port C latches. There area several things that can cause the PORTC voltages to be different from the port C latches.
The ones that I know of are:-
The TRISC bits are set high so that the pin is an output.
The output is overloaded by an external load.
The output is still changing from a previous command.
So reading PORTC is a very unreliable way of finding out the contents of the port C latch.
So don't do it.
With a shadow register, you define any convenient register as the port shadow, and define its state, normally by clearing it. During program running, you can change bits on that shadow with no problems, because it is a normal register and there is no RMW problem. Then the
only port write you do is:-
PORTC = portc_shadow;
So the port C latches are what you want them to be.
Your code was just a long winded way of replicating the problem because you read the port at the start.
18F and 24F processors have separate latch registers, which you can set bits on because reading them does not read the state of the pins, it just reads the state of the latch. I am fairly sure that was added to get over the RMW problem.