[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] direct port access
From: |
Volkmar Dierkes |
Subject: |
Re: [avr-gcc-list] direct port access |
Date: |
Thu, 23 Jan 2003 00:31:31 +0100 |
User-agent: |
40tude_Dialog/2.0.3.1 Hamster/2.0.0.0 |
On Wed, 22 Jan 2003 14:58:38 -0700, E. Weddington wrote:
> On 22 Jan 2003 at 10:57, Marlin Unruh wrote:
>
>> I have some code that was working with the old style io.h. I am tring
>> to get the code working with the new style (#define
>> PORTD _SFR_IO8(0x12))
>>
>> void Pdu1_In_Port(unsigned char* buff)
>> {
>> unsigned char tmp;
>> unsigned char * const iobase = (unsigned char*)0x20;
>> unsigned char address;
>> address = buff[10]; // get address of port
>> if(address < SPL) { // exclude SREG and Stack Pointer Registers
>> tmp = *(iobase + address); // read i/o space address
>> tmp &= ~buff[6]; // inverted mask low byte AND
>> tmp |= (buff[6] & buff[8]); // get data low byte
>> *(iobase + address) = tmp; // write i/o space
>> }
>> } // end of Pdu1_In_Port
>>
> <snip>
>
> Well you didn't say what the above code is actually doing in it's
> error.
>
> But this could be a problem:
>
> if(address < SPL) { // exclude SREG and Stack Pointer Registers
>
> SPL is defined as a _SFR_IO8(..., which is not going to be the same
> thing as what your address is declared as. Rewrite as:
>
> if(address < &(SPL))
>
> That way you're comparing a memory address to a memory address.
Eric,
I think he want to use adress as a pointer to a io register. But
adress is now a pointer to memory. I didn't know how to declare
adress as an pointer to IO, but I think that leads to the solution.
Volkmar
avr-gcc-list at http://avr1.org