Hi Indana,
Lets take the 64 1st
Code: Select all
If you have 128 64 32 16 8 4 2 1
In Binary 64 (Decimal) = 0 1 0 0 0 0 0 0
You can see bit under the 64 is high(1) all the rest are low(0)
Going from the far right bit = Least Significant Bit or LSB = bit 0 (there are eight bits in total), the high bit is bit 6
If you had an output icon set to the whole port eg portB, and was assigned with the value of 64 then pin conected to portB6 would be the only pin that will be high (at +5V)
all the rest of the port will be set low (0V)
Masking:
Suppose none of the bits on the output Icon was masked and decmal value assigned to portB is 100
Code: Select all
If you have 128 64 32 16 8 4 2 1
In Binary 100 (Decimal) = 0 1 1 0 0 1 0 0 = 64+32+4
So bits 6,5 & 2 are all high and the remaining bits left will be low.
If you mask bit 6 (select Entire port, Use Masking, bit6)

- Masking1.jpg (35.64 KiB) Viewed 15490 times
Then only bit 6 is ever effected, so only bit 6 will be high, or with 0 as a value will go low.
This is the same as selecting output to a single bit and using 1 for bit = on and 0 for bit = off
I have use masking when I want more than one bit(or pin) to be affected, but not all 8 bits.
So it has nothing to do with counting 64 times.
Hope this helps
Martin