On Mon, 31 Jan 2005 09:47:49 -0500 (EST), <ethan@bufbotics.org> wrote:
>
> <code>
> if (turn_motor_on) {
> setbit(MOTOR_ENABLE_PORT, MOTOR_ENABLE_PIN);
> } else {
> clrbit(MOTOR_ENABLE_PORT, MOTOR_ENABLE_PIN);
> }
> </code>
> Personally, I would prefer something like.....
> <code>
> write_bit(turn_motor_on, MOTOR_ENABLE_PORT, MOTOR_ENABLE_PIN);
> </code>
You could make that with a define i think. I guess even i could figure out
how eventually.
But well, wouldn't it be great if one could just write
MOTOR_ENABLE_PIN = turn motor on;
or, if need be
MOTOR_ENABLE_PORT.MOTOR_ENABLE_BIT = turn motor on;
I have the same situation here.
I don't understand why that doesn't work. I'm no programmer as everyone
sees easily, but when reading various stuff i get the impression "well, if
you don't use bit operations you aren't a proper programmer, get lost.".
That might well be true, and i'm not a proper programmer, but i still
don't understand why i must fight with &|!<< to change or read a single
bit.
I mean, life is hard enough, why make it any harder?
Why exactly is't a bit just a variable like for example PORTB?
I can write PORTB=0xFF; but can't do the same with bits.
STMessage
Re: [AVR-Chat] accessing bits (e.g. of ports)
2005-01-31 by Stefan Trethan
Attachments
- No local attachments were found for this message.