Yahoo Groups archive

Lpc2000

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

Thread

congratulations

congratulations

2005-01-15 by Thomas Patrick

Hello guys, 
 
                  I congratulate all members of this group for being so actively participating and keeping this group so alive. I have found the discusions and topics discuss are interesting. As a new member, I hope I will too contribute to this group. 
 
   For my next project I choosed lpc2129. I read the user manual and would like to discuss a small doubt.   
 

GPIO Pin Value Register IOPIN

This register provides the value of the GPIO pins. Register�s value reflects any outside world influence on the GPIO configured.

example: 

 IOSET0 = 0x00000050;  /* Declare P0.4 & P0.6 as output ports*/

 Unsigned int value; /* Declare Variable of type Int */

 IOPIN0 = 0x00000020;  /* Reflects changes on P0.5 Port */

 value = IOPIN0;  /* reads the digital input value on P0.5*/

        The above program reads the digital input at port P0.5 and holds the value in integer variable value. 

In Data sheet it is given as 

Applications that require instanatneous appearance of zeros and ones on the respected parallel port can use direct access to

port�s corresponding GPIO Pin Value Register (IOPIN).

Assuming that pins P0.8 to P0.15 are configured as output, write to IO0PIN:

IO0PIN = 0x0000 C700

will produce the same output as following sequence of writes:

IO0SET = 0x0000 C700

IO0CLR = 0x0000 3800

if I go by above statements and declare IOPIN0 = 0x00000020 gives IOSET0 = 0x00000020 and IOCLR0 = 0x000000D0 which clears my P0.4 and P0.6, which I declare them as outport ports to generate 1. 

          This will not serve my purpose .....then how can I access the digital input value on P0.5 ???

I hope guys in this group have answers.

greetings,

Thomas 

 

 

 

pins only.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

[Non-text portions of this message have been removed]

Re: [lpc2000] congratulations

2005-01-15 by microbit

Hi Thomas,

Welcome !

> Assuming that pins P0.8 to P0.15 are configured as output, write to IO0PIN:
> IO0PIN = 0x0000 C700
> will produce the same output as following sequence of writes:

> IO0SET = 0x0000 C700
> IO0CLR = 0x0000 3800

No, IOSET and IOCLR avoid a so called "Read-Modify-Write" instruction. (RMW)
Normally on most MCUs, you will eg. do this :

Port |=    0x10;        /* Set Bit 4 on <Port>

This Reads the output latches (or actual outputs) on <Port>, ORs it with 0x10 and then
writes it back, resulting in Bit 4 being SET.

This operation can be done with JUST writing to IOSET :

IOSET = 0x10;        /* Set Bit 4 */

Same goes for Clearing bits.

Now, direct writes to IOPIN _effectively_ write the whole Port , thus :

> IO0PIN = 0x0000 C700

Will write "0x0000 C700" to the WHOLE Port 0.
This means that will produce the same output as following sequence of writes:

IO0SET = 0x0000 C700;        /* Bits 8 & 15 are set to "1"  */
IO0CLR = 0xFFFF 38FF;        /* All other bits are cleared */

Your sequence of writes :

> IO0SET = 0x0000 C700
> IO0CLR = 0x0000 3800

doesn't achieve anything : First Bits 8 & 15 are SET, then on next line they are CleaRed !!!

Some MCUs are "true" RMW, some not.

This used to be a huge problem on eg. PIC.
The early PIC16C71 had a TRISA (direction PortA) and PORTA (I/O Port A).
Now, when you used BSET and BCLR instruction, things would go haywire on Port A...
(TrisA wasn't disabling the PA3)

PA3, bit 3 (IIRC) was an open collector output, and when you eg. did this :

SETB    PortA , 0x01        /* Set Bit 1 on Port A */

AND PA3 was an input (there was no "direction" for PortA), the following would happen :

Port A is read, OR with 0x01, write back.
So, if you were using PA3 as an INPUT, and it happened to have a LOW level on that pin,
The SETB instruction would pull down the PA3 pin, disbling its ability to read the actual input... !!!

Hope that clears it all up..

B rgds
Kris



[Non-text portions of this message have been removed]

Re: [lpc2000] congratulations

2005-01-15 by microbit

Ho, misread this part :

> Your sequence of writes :
> 
> > IO0SET = 0x0000 C700
> > IO0CLR = 0x0000 3800
> 
> doesn't achieve anything : First Bits 8 & 15 are SET, then on next line they are CleaRed !!!

That should be :
Bits 15, 14 and 10,9,8 are SET.
Then Bits 13,12 and 11 are CLeaRed.

Sorry !

Also,

> IO0SET = 0x0000 C700;        /* Bits 8 & 15 are set to "1"  */

Should of course have read : 
/* Bits 8,9,10 & 14,15 are set to "1"  */

B rgds
Kris


[Non-text portions of this message have been removed]

Re: [lpc2000] congratulations

2005-01-15 by Robert Adsett

Adding to Kris's answer

At 06:05 AM 1/15/05 -0800, you wrote:
<snip>
>GPIO Pin Value Register IOPIN
>
>This register provides the value of the GPIO pins. Register's value 
>reflects any outside world influence on the GPIO configured.
>
>example:

<snip>


>  value = IOPIN0;  /* reads the digital input value on P0.5*/
>
>         The above program reads the digital input at port P0.5 and holds 
> the value in integer variable value.

<snip>

>if I go by above statements and declare IOPIN0 = 0x00000020 gives IOSET0 = 
>0x00000020 and IOCLR0 = 0x000000D0 which clears my P0.4 and P0.6, which I 
>declare them as outport ports to generate 1.
>
>           This will not serve my purpose .....then how can I access the 
> digital input value on P0.5 ???

value = IOPIN0;

Just as it says in the example.

Remember that you must set the appropriate IODIR register correctly as well.

BTW, the above sequence sets pin 0.5 high (and all others low),  Then sets 
pin 0.5 high again (leaving the others undisturbed) , and finally clears 
pins 0.7, 0.6 and 0.4 while leaving the other pins unaffected.

If pin 0.5 is an input then it's value won't be affected by any of this.

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

Re: congratulations

2005-01-15 by Leighton Rowe

Hey Thomas,

The lpc2129 User Manual contains all the info u need on GPIO 
manipulation. Just note the following whenever you're manipulating 
Port0.

- You 'only' can read current GPIO pin states by reading the IO0PIN 
register. 

Variable = IO0PIN; 

- The User Manual defines IO0PIN to be a read-only register. 
IO0PIN = 0x0000 C700; // invalid statement (according to IAR compiler)

- IO0CLR,IO0SET writes is the only way of changing output pin states. 
- Writing 1's to the bits of IO0SET will make the corresponding pins 
High. 
- Writing 1's to the bits of IO0CLR will make the corresponding pins 
Low.

So with the statements u have:
IO0SET = 0x0000 C700  
IO0CLR = 0x0000 3800 //theres no need for this. Also note that:

- Writing 0's to IO0CLR/IO0SET has no effect on Port0. 

Using the IO0CLR/IO0SET registers facilitates a more disciplined 
approach towards output control.

Re: [lpc2000] Re: congratulations

2005-01-15 by Robert Adsett

At 03:07 PM 1/15/05 +0000, you wrote:
>- You 'only' can read current GPIO pin states by reading the IO0PIN
>register.
>
>Variable = IO0PIN;
>
>- The User Manual defines IO0PIN to be a read-only register.
>IO0PIN = 0x0000 C700; // invalid statement (according to IAR compiler)

Actually, the user manual appears to be of (at least) two minds about this 
point.  For instance in the 2106 users manual the following line appears in 
the description of IOPIN

"Note: for test purposes, writing to this register stores the value in the 
output register, bypassing the need to use both the IOSET and IOCLR registers"

As well other user manuals mention its use to set and clear bits 
simultaneously.

I suspect the two parts were written by different people and have not been 
properly reconciled.  More to the point I believe (but haven't verified) 
that IOPIN is in fact writeable.  Of course once you start using it in that 
fashion you have to protect it against access from multiple threads of 
control, provide shadows etc, it's sort of an all or nothing step.  You 
could, however do much faster simulation of something like an expansion bus.

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

Re: [lpc2000] Re: congratulations

2005-01-17 by Thomas Patrick

Hello guys, 
 
                    Thanks for the replies. Its actaually not so confusing. What I came to know is when you declare port pin as input then you can read the value of digital input on register IOPIN for that respective port pin. 
 
  if you declare port pin as output then you write on IOPIN register ..It generates 1's and 0's simulatenously. 
 
 cheers,
 
 Thomas  
 


Leighton Rowe <leightonsrowe@...> wrote:

Hey Thomas,

The lpc2129 User Manual contains all the info u need on GPIO 
manipulation. Just note the following whenever you're manipulating 
Port0.

- You 'only' can read current GPIO pin states by reading the IO0PIN 
register. 

Variable = IO0PIN; 

- The User Manual defines IO0PIN to be a read-only register. 
IO0PIN = 0x0000 C700; // invalid statement (according to IAR compiler)

- IO0CLR,IO0SET writes is the only way of changing output pin states. 
- Writing 1's to the bits of IO0SET will make the corresponding pins 
High. 
- Writing 1's to the bits of IO0CLR will make the corresponding pins 
Low.

So with the statements u have:
IO0SET = 0x0000 C700  
IO0CLR = 0x0000 3800 //theres no need for this. Also note that:

- Writing 0's to IO0CLR/IO0SET has no effect on Port0. 

Using the IO0CLR/IO0SET registers facilitates a more disciplined 
approach towards output control. 









---------------------------------
Yahoo! Groups Links

   To visit your group on the web, go to:
http://groups.yahoo.com/group/lpc2000/
  
   To unsubscribe from this group, send an email to:
lpc2000-unsubscribe@yahoogroups.com
  
   Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 


		
---------------------------------
Do you Yahoo!?
 Yahoo! Mail - You care about security. So do we.

[Non-text portions of this message have been removed]

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.