This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Assign name to pin

Hi all,
I searched the forum before starting
this thread, but I couldn't find a
satifying answer to my question.

here's my question:
I'm using keil uVision2 and the EZ-USB FX
dev kit. This kit has 6 IO ports on it.
I want to assign a name to each pin
of the IO ports.
This is what I tried so far:
...
#define D0 OUTB.0
main()
{
D0 = 1;
}
...
I get 2 errors:
error C141: syntax error near '.0'
error C213: left side of asn-op not an lvalue

As far as I remember I used this code in
a previous project, and it worked. But now it doesn't :(

anyone who knows what goes wrong?

kind regards,
Chris

Parents
  • It is pity that C51 does not handle bit-fields efficiently

    Few compilers handle C bitfields efficiently. Given my bad experiences with that, plus the fact that bitfields are under-specified* and thus not very portable, I've learned to avoid their use entirely and just use bitwise operators instead.

    The Keil sbit mechanism is one of those low-level 8051 architecture adaptations. Since only the occasional SFR and a few bytes of memory are bit-addressable, it really wouldn't do as a mechanism for general bitfields.

    (* Common snags: The order of bitfields in a word is not standardized, and varies from compiler to compiler. Despite the fact that bitfields are specifically "int", whether or not a value with the high bit set is negative is implementation-dependent, so it's risky to use some tests on a bitfield or pass them as parameters. Standard C insists that bitfields are always an int wide, even if you declare only one bit, though most decent embedded compiler lets you declare them in ints of various sizes as an extension.)

Reply
  • It is pity that C51 does not handle bit-fields efficiently

    Few compilers handle C bitfields efficiently. Given my bad experiences with that, plus the fact that bitfields are under-specified* and thus not very portable, I've learned to avoid their use entirely and just use bitwise operators instead.

    The Keil sbit mechanism is one of those low-level 8051 architecture adaptations. Since only the occasional SFR and a few bytes of memory are bit-addressable, it really wouldn't do as a mechanism for general bitfields.

    (* Common snags: The order of bitfields in a word is not standardized, and varies from compiler to compiler. Despite the fact that bitfields are specifically "int", whether or not a value with the high bit set is negative is implementation-dependent, so it's risky to use some tests on a bitfield or pass them as parameters. Standard C insists that bitfields are always an int wide, even if you declare only one bit, though most decent embedded compiler lets you declare them in ints of various sizes as an extension.)

Children
No data