Hi,

I know there are the bitwise operators to work at bit level. I'm not familiar with these and logic was never my strong point. That's why I would need some help here.

I'm using a 7 segments led display (plus a dot, which makes 8 leds, and two ground pins, for a total of 10 pins).
Each segment is a led. The 7 sements (plus the dot led) have common cathode.
Each led anode is connected to a pin of a PIC16F684. So to turn on a segment, I just need to output 5V on the appropriate pin. To display a digit, I just have to turn on the appropriate pins/segments/leds.

I'm using RC4 to RC0 for 5 of the 7 segments (segments a to e) and RA1 to RA2 for the 2 last segments (f, g) (while the "dp" dot is on RA0).

I have to set the appropriate pins to display the adequate segments to display a digit.
For example, to display digit "0", I need to turn on the pins that will light the segments a, b, c,d, d, e, f, thus, for my design, the pins RC4 to RC0 and RA1. (a little complicated, yes).
Anyway, I have to set portA and portC to:


porta: xxxx10x, portc: x11111

where the "x" represent bits that must not be changed.

How can I replace the needed bits without changing the "x" bits?

I guess I should use bits mask but what is the magic?

Thanks for any help here.

Regards.