EmbeddedRelated.com
Forums

Fast GPIO on LPC2103

Started by slb885 March 1, 2007
I seem to be having some trouble getting the "fast" GPIO on my LPC2103
working. Here is the code I use for the normal GPIO (which works)

---
IODIR |= (1<<24);

ms_delay(500);

IOSET = (1<<24);
ms_delay(500);
IOCLR = (1<<24);
ms_delay(500);
IOSET = (1<<24);
ms_delay(500);
IOCLR = (1<<24);
---
And here is the code I am using for the fast GPIO

---
FIOMASK |= (1<<24);
// Also tried FIOMASK = 0 here

FIODIR |= (1<<24);

FIOSET = (1<<24);
ms_delay(500);
FIOCLR = (1<<24);
ms_delay(500);
FIOSET = (1<<24);
ms_delay(500);
FIOCLR = (1<<24);
ms_delay(500);
---
I have tried making sure that P.24 in FIOMASK is high and low, but
neither seems to work. Which is is supposed to be, a 0 or a 1? The
datasheet is unclear:

[Description for setting a "1" to a bit in FIOMASK]
"Physical pin is unaffected by writes into the FIOSET, FIOCLR and
FIOPIN registers. When the FIOPIN register is read, this bit will not
be updated with the state of the physical pin."
(So a 1 = "unaffected by write")

But than later...

[Description of FIOSET]
"Fast GPIO Port Output Set register using FIOMASK. This register
controls the state of output pins. Writing 1s produces HIGH at the
corresponding port pins. Writing 0s has no effect. Reading this
register returns the current contents of the port output register.
Only bits enabled by ones in FIOMASK can be altered."
(So a 1 = "can be altered")

So is a 1 or a 0 enabled?!?!?

Thanks for any help,

Scott

An Engineer's Guide to the LPC2100 Series

--- In l..., "slb885" wrote:
>
> I seem to be having some trouble getting the "fast" GPIO on my
> LPC2103 working. Here is the code I use for the normal GPIO (which
> works)

Check this in the start of the GPIO chapter:

"User must select whether a GPIO will be accessed via registers that
provide enhanced features or a legacy set of registers (see Section
3.6.1 "System Control and Status flags register (SCS - 0xE01F C1A0)"
on page 23)."

The fast GPIOs don't work until you set bit 0 in SCS.

> I have tried making sure that P.24 in FIOMASK is high and low, but
> neither seems to work. Which is is supposed to be, a 0 or a 1? The
> datasheet is unclear:
>
> [Description for setting a "1" to a bit in FIOMASK]
> "Physical pin is unaffected by writes into the FIOSET, FIOCLR and
> FIOPIN registers. When the FIOPIN register is read, this bit will
> not be updated with the state of the physical pin."
> (So a 1 = "unaffected by write")
>
> But than later...
>
> [Description of FIOSET]
> "Fast GPIO Port Output Set register using FIOMASK. This register
> controls the state of output pins. Writing 1s produces HIGH at the
> corresponding port pins. Writing 0s has no effect. Reading this
> register returns the current contents of the port output register.
> Only bits enabled by ones in FIOMASK can be altered."
> (So a 1 = "can be altered")

Looks like an error in the manual.

> So is a 1 or a 0 enabled?!?!?

When a FIOMASK bit is 0 (the reset value) you can read and modify the
port pin.

Karl Olsen
Oh, I didn't notice the SCS register. Thanks a lot for that,
hopefully I'll get that working later tonight than.

thanks!

-Scott

--- In l..., "Karl Olsen" wrote:
>
> --- In l..., "slb885" wrote:
> >
> > I seem to be having some trouble getting the "fast" GPIO on my
> > LPC2103 working. Here is the code I use for the normal GPIO (which
> > works)
>
> Check this in the start of the GPIO chapter:
>
> "User must select whether a GPIO will be accessed via registers that
> provide enhanced features or a legacy set of registers (see Section
> 3.6.1 "System Control and Status flags register (SCS - 0xE01F C1A0)"
> on page 23)."
>
> The fast GPIOs don't work until you set bit 0 in SCS.
>
> > I have tried making sure that P.24 in FIOMASK is high and low, but
> > neither seems to work. Which is is supposed to be, a 0 or a 1? The
> > datasheet is unclear:
> >
> > [Description for setting a "1" to a bit in FIOMASK]
> > "Physical pin is unaffected by writes into the FIOSET, FIOCLR and
> > FIOPIN registers. When the FIOPIN register is read, this bit will
> > not be updated with the state of the physical pin."
> > (So a 1 = "unaffected by write")
> >
> > But than later...
> >
> > [Description of FIOSET]
> > "Fast GPIO Port Output Set register using FIOMASK. This register
> > controls the state of output pins. Writing 1s produces HIGH at the
> > corresponding port pins. Writing 0s has no effect. Reading this
> > register returns the current contents of the port output register.
> > Only bits enabled by ones in FIOMASK can be altered."
> > (So a 1 = "can be altered")
>
> Looks like an error in the manual.
>
> > So is a 1 or a 0 enabled?!?!?
>
> When a FIOMASK bit is 0 (the reset value) you can read and modify the
> port pin.
>
> Karl Olsen
>