manipulating bits on PORTx
manipulating bits on PORTx
Is there a way to manipulate bits on any port as a vector??
Re: manipulating bits on PORTx
Hi,
Please, can you tell me what exactly did you have in mind ?
Regards,
Filip.
Please, can you tell me what exactly did you have in mind ?
Regards,
Filip.
Re: manipulating bits on PORTx
Well, I would like to do somthing like this:
I'm using a pic16F887..
for (i=0;i<8;i++) {
PORTB = 1;
delay_ms(1000);
}
This code will generate an Error when compiled, but, is there a way to manipulate a register's bits like an array?? Do I have to write my own library??
And also I know that it is not possible to declare a bit type array :'(..
Thanks for fast respond...
I'm using a pic16F887..
for (i=0;i<8;i++) {
PORTB = 1;
delay_ms(1000);
}
This code will generate an Error when compiled, but, is there a way to manipulate a register's bits like an array?? Do I have to write my own library??
And also I know that it is not possible to declare a bit type array :'(..
Thanks for fast respond...
Re: manipulating bits on PORTx
Hi,
Well, you could do this in this way :
Basically, you assign to the PORTB predefined values from the declared vector (array).
Regards,
Filip.
Well, you could do this in this way :
Code: Select all
char i;
char array[] = {1,2,4,8,16,32,64,128,255};
void main() {
for (i=0;i<8;i++) {
PORTB = array[i];
}
}
Regards,
Filip.