Yahoo Groups archive

Lpc2000

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

Message

Re: [lpc2100] GPIO Questions!

2004-02-14 by Robert Adsett

At 06:14 AM 2/14/04 -0800, you wrote:
>1) The data Sheet says IOPIN register isnt Byte Accessable, does that mean 
>I cant write macros to read specific bits of the register,eg...
>
>#define DATA         (((PORT_32BIT_PTR)(IOPIN)->bits.bit8)
>
>where PORT_32BIT_PTR is a bitfield.

I expect that would work but I'd want to verify it, unless IOPIN is not 
defined as a pointer. On the other hand if IOPIN is not a pointer this 
would work a lot better.

#define DATA ((IOPIN & MASK_DBIT) >> BIT_OFFSET)

or

#define DATA (((PORT_32BIT_PTR)(&IOPIN))->bits.bit8)

The more I think of it the less likely I see IOPIN being defined as a 
pointer unless you defined it that way yourself.

>Likewise with the strobe line, except that the pointer is to the IOSET or 
>IOCLR register
>If I cant do this is there another way to access specific bits of the IO 
>Input Register? or do I have to read the entire port?

Using this structure for IOSET and IOCLR is probably not a good idea.  It 
will translate to a read-modify-write sequence which will work fine for 
IOSET but since IOCLR is a write only register it's not clear what will 
happen to it.  I'd use something like

#define STROBE_BIT_MASK (0x100)
#define STROBE_HIGH() (IOSET = STROBE_BIT_MASK)
#define STROBE_LOW() (IOCLR = STROBE_BIT_MASK)

I suspect you will end up reading the entire port regardless of how you 
write the code.  It will not make any difference to the timing or behaviour 
in any case.

>
>2) The reader has 10K pullups on the STROBE and DATA lines and I was 
>wondering if these are to much?I know this question have been asked before 
>so I apologise for asking somebody to repeat themselves!!!

10K always strikes me as weak.  I'm using 4K7 without any problems.

>
>The last question..(I Think!) is how fast can I strobe the IO lines, the 
>reader has a maximum read speed of 10MBits/s so if i do some thing like....
>         STROBE=0;
>             Sleep(100);
>        STROBE=1;
>Is there is delay between clearing a bit and the like actually going low?

We actually had a discussion of this earlier in the group.  See 
http://groups.yahoo.com/group/lpc2100/message/37 The fastest I have managed 
to set and clear a pin is on the order of 120ns.  Add in some non-linear 
code and some decision making and I doubt you'll have too much trouble 
restraining yourself :)


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

Attachments

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.