----- Original Message -----
From: "Stefan Trethan" <stefan_trethan@gmx.at>
To: <AVR-Chat@yahoogroups.com>
Sent: Monday, January 31, 2005 4:29 PM
Subject: Re: [AVR-Chat] accessing bits (e.g. of ports)
>
> On Mon, 31 Jan 2005 15:44:06 -0000, Leon Heller
> <leon.heller@dsl.pipex.com> wrote:
>
>> In most languages, including C, you can't manipulate individual bits
>> directly in the same way as other data types like ints, chars, etc. High
>> level languages don't usually know about anything smaller than a byte.
>> You
>> can manipulate individual bits in assembler. For instance:
>> sbi portb,PB2
>> sets bit 2 of port B
>> and
>> cbi portb,PB2
>> clears bit 2 of port B
>> and many embedded C compilers have language extensions that let you use
>> in-line assembler by writing something like:
>> asm("sbi portb,PB2");
>> Leon
>
>
> Leon, that is something that i have known, but never understood.
> You see, i see no reason why a bit shouldn't be a data type. I mean if you
> can distinguish between 8 bit and 16 bit words why not make a bit type?
> But i have heared several good programmers complain about that
> shortcoming.
>
> But regardless of what C wants, isn't there a way of fooling it into
> cooperation?
> Isn't there _any_ way of using bits like bytes? (e.g. PB0=1; ).
You can do something like that with bit-fields and memory-mapped I/O, but
the technique won't work for I/O as it is implemented on the AVR.
Leon
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.8.2 - Release Date: 28/01/2005Message
Re: [AVR-Chat] accessing bits (e.g. of ports)
2005-01-31 by Leon Heller
Attachments
- No local attachments were found for this message.