Discussion in "ARM Development" started by    Rakesh hasija    Sep 7, 2009.
Mon Sep 07 2009, 06:47 pm
#1
Lpc2138 hve 47 gpio which can be act input or output,i m right na

#define K1 0x00000080 //p0.11
#define k2 0x00001000 //p0.12
#define k3 0x02000000 //p0.25

now how i define port P1.25 or P1.24.
plz help me out
Mon Sep 07 2009, 09:06 pm
#2
#define k3 0x02000000 //p0.25
only defines a bit position, it does not specify the port, so k3 could be
on port 0 or 1.
It depends which port you write to.

Check your compiler for ways to define a bit on a particular port.

Tue Sep 08 2009, 12:18 am
#3
#define K1 0x00000080
does not mean //p0.11 it means that the 11th bit has a one on it
can also be written as
#define K1 (0x01<<11)
now
IODIR0 =K1 ==> direction of the 11th pin of port0 is 1 i.e. output
IOSET0 =K1 ==> value of the 11th pin of port0 is 1 i.e. high
IOCLR0 =K1 ==> value of the 11th pin of port0 is 0 i.e. Low

similarly you can go for port 1.
IODIR1 =K1 ==> direction of the 11th pin of port1 is 1 i.e. output
IOSET1 =K1 ==> value of the 11th pin of port1 is 1 i.e. high
IOCLR1 =K1 ==> value of the 11th pin of port1 is 0 i.e. Low

check the header file for exact representation of gpio registers.
Tue Sep 08 2009, 01:27 am
#4


#define K1 0x00000080
does not mean //p0.11 it means that the 11th bit has a one on it

shyam


Whatever it means I think the 12'th bit/pin would actually be..
#define K1 0x00000800


[ Edited Tue Sep 08 2009, 01:42 am ]
Wed Sep 09 2009, 09:01 pm
#5
yes shyam i agree wid u but when we declare any port pin as input thn we can't use ioset and ioclr instruction,right na...
now i have to set that input pin to the high value,how can i do that
Wed Sep 09 2009, 09:08 pm
#6
You can't set an input pin as high or low, you can only read it.
If you want to control its level, define it as an output in IOxDIR.
Then you can use the P0xCLR and P0xSET instructions.


[ Edited Wed Sep 09 2009, 09:16 pm ]
Thu Sep 10 2009, 10:46 am
#7
if you want to set default value of any pin as high try using
IOPIN0/1 = 0x01<<(pin); before going for IODIR0/1
anyway this is not required to do at all.

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Clydehet
Wed May 01 2024, 06:44 pm
Davidoried
Wed May 01 2024, 06:11 pm
KevinTab
Sun Apr 28 2024, 05:35 am
Tumergix
Sun Apr 28 2024, 12:59 am
StevenDrulk
Sat Apr 27 2024, 08:47 pm
StephenHauct
Sat Apr 27 2024, 09:38 am
Adamsaf
Sat Apr 27 2024, 07:12 am
Robertphype
Sat Apr 27 2024, 12:23 am