Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Thread

Port Reading

Port Reading

2004-09-01 by Leighton Rowe

When reading bits 16:23 of I/O Port1 into a byte variable, I'd 
normally do something like this...

unsigned char Variable;
Variable = (IO1PIN >> 16)& 0xff;

I'm thinking of instead using a character pointer to access bits 
16:23 (speeds up execution time). 

Variable = *Read_ptr;  
//where  (unsigned char*)Read_ptr --> IO1PIN (bit 16:23)

If this is possible, I'm not sure on the partial memory location 
that I must set the pointer to. Are the pin values for the IO1PIN 
register stored in little or big endian order?

Re: [lpc2000] Port Reading

2004-09-01 by Robert Adsett

At 01:54 PM 9/1/04 +0000, you wrote:
>When reading bits 16:23 of I/O Port1 into a byte variable, I'd
>normally do something like this...
>
>unsigned char Variable;
>Variable = (IO1PIN >> 16)& 0xff;
>
>I'm thinking of instead using a character pointer to access bits
>16:23 (speeds up execution time).
>
>Variable = *Read_ptr;
>//where  (unsigned char*)Read_ptr --> IO1PIN (bit 16:23)
>
>If this is possible, I'm not sure on the partial memory location
>that I must set the pointer to. Are the pin values for the IO1PIN
>register stored in little or big endian order?

I thought I remembered something about peripherals and word access in the 
user manual so I went and looked it up.  From the bottom of p49 of the 2119 
user manual:

"All peripheral register addresses are word aligned (to 32-bit boundaries) 
regardless of
their size. This eliminates the need for byte lane mapping hardware that 
would be required to allow byte (8-bit) or half-word (16-
bit) accesses to occur at smaller boundaries. An implication of this is 
that word and half-word registers must be accessed all at
once. For example, it is not possible to read or write the upper byte of a 
word register separately."

Robert

" 'Freedom' has no meaning of itself.  There are always restrictions,
be they legal, genetic, or physical.  If you don't believe me, try to
chew a radio signal. "

                         Kelvin Throop, III

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.