avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-libc-dev] Determine defined port


From: E. Weddington
Subject: Re: [avr-libc-dev] Determine defined port
Date: Mon, 23 Aug 2004 09:17:09 -0600
User-agent: Mozilla Thunderbird 0.7.3 (Windows/20040803)

Harald Kipp wrote:

Hi all,

I stumbled over the following pre-processor problem.

Somewhere in an include file there's a macro

  #define MY_PORT  PORTC

User's should be able to adapt the program to their hardware
be simply changing this include file.

To make the code independent from the specified port,
I need something like

  #if (MY_PORT == PORTC)
  /* Do something PORTC specific, like disabling XMEM */
  #endif
  sbi(MY_PORT, 7);

Obviously this won't work, because PORTC is an already dereferenced
volatile pointer. No chance to retrieve the pointer address, right?

Actually you *can* retrieve the pointer address. The register names can be used as variables, so you can take the address of it like so:

&PORTC

HTH
Eric





reply via email to

[Prev in Thread] Current Thread [Next in Thread]