No, I'm afraid it won't work; you will have to make the 'set' and 'clear' masks by yourself:
Code: Select all
unsigned short bitmask_set[] = {0b00000001, 0b00000010, 0b00000100, 0b00001000,
0b00010000, 0b00100000, 0b01000000, 0b10000000};
unsigned short bitmask_clr[] = {0b11111110, 0b11111101, 0b11111011, 0b11110111,
0b11101111, 0b11011111, 0b10111111, 0b01111111};
void main() {
int i = 0;
while(1) {
if(PORTD.f1 == 1) // you can do this for constant pin No.
{
// PORTB.i = 1;
PORTB |= bitmask_set[i]; // ...but for the variable pin No, you must
Delay_ms(1000); // do this to set it...
// PORTB.i = 0;
PORTB &= bitmask_clr[i]; // ...and this to clear the pin.
i++;
// if(i == 8) i = 0;
i &= 0x07; // this is cheaper than if..then
}
}
}//~!