Discussion in "ARM Development" started by    shyam    Dec 22, 2007.
Sun Dec 23 2007, 12:41 am
#11
thnks ajay u r right......
i'll edit it..


now read....

thus IODIR1 = 0xFF000000 => pins P1.24 - P1.31 are configured as output

Sun Dec 23 2007, 12:45 am
#12
got it thank you...
have to click thanks button.. forgot it
Sun Dec 23 2007, 01:17 pm
#13
all this while we have been trying to use IOs as output pins......

but we require them as inputs too.....

this is where IOPIN comes in

IOPIN ==> GPIO Port Pin value register. The current
state of the GPIO configured port pins can
always be read from this register, regardless
of pin direction.

thus consider the sequence....

IODIR1 =0xFF;
IOSET1 = 0x0F;
IOCLR1 = 0x02;
Int_Buffer = IOPIN1;


value of Int_Buffer = 0x0D...

imp note =>


IODIR1 =0xFF;


=> P1.0 - P1.7 has been configured as output pins......
we can not take input at these input...

thus look again at the above stated sequence...

now if i have a press-2-on switch on pin P1.0... can i read the status????


no....

the IOPIN1 will still return 0x0D..

there fore the IODIR1 shud be written
IODIR1 = 0xFE;

points to remember.....

1. status of port pins can only be read thru IOPIN register.....
2. IODIR has a default value of 0x00 so by default port pins are configured as input.
3. change in IOSET register has no effect on IOCLR and vice versa..
4. IODIR IOSET IOCLR IOPIN are all individual 32 bit registers..
5. a pin once configured as output can not be used as input unless the value of corresponding IODIR register is changed.
6.ports in LPC/arm are not bit addressable!!

this is all about writing to a pin and reading from pins

next we will discuss the PINSEL register....
 ajay_bhargav like this.
Sun Dec 23 2007, 04:44 pm
#14
Just see this example
Can we dry run this ?
Sun Dec 23 2007, 04:45 pm
#15
run what???
Sun Dec 23 2007, 04:48 pm
#16
Just see this example
can we dry run this
/*
	LEDRing.c
	
	Lights a different LED every second.
	
	LEDs are active-low
*/


#include <Philips\LPC2148.h>
 //
#include <Philips\LPC2138.h>
 //

#define	T0PR		(*((volatile WORD32 *) 0xE000400C))
#define	VPBDIV		(*((volatile WORD32 *) 0xE01FC100))
#define	IO1PIN		(*((volatile WORD32 *) 0xE0028010))
#define	IO1SET		(*((volatile WORD32 *) 0xE0028014))
#define	IO1DIR		(*((volatile WORD32 *) 0xE0028018))
#define	IO1CLR		(*((volatile WORD32 *) 0xE002801C))

#include "Timer0.h"

int main(void)
{
	unsigned long pin;
	int i;
	
	InitTimer0();
	
	PINSEL0=0;	// PINSEL(0,1,2) = 0 configures pins as GPIO
	PINSEL1=0;	// (probably not necessary: PINSELs default to zero)
	PINSEL2=0;
	
	
	// IOxDIR: setting a bit to one designates the pin as output
	IO0DIR=0xFFFFFFFF;	// P0.0-P0.31 are output
	IO1DIR=0x03FF0000;	// P1.25-P1.16 are output

	for(;;) {
		IO1PIN=0xFFFFFFFF;
		for(i=0,pin=1; i<32; pin<<= 1,i++) {
			IO0PIN=~pin;
			WaitForNextTick();
		}
		IO0PIN=0xFFFFFFFF;
		for(pin=0x00010000; pin<=0x02000000; pin <<= 1) {
			IO1PIN=~pin;
			WaitForNextTick();
		}
	}
}


[ Edited Sun Dec 23 2007, 05:27 pm ]
Sun Dec 23 2007, 04:53 pm
#17
hi vinay ...

consider my previous post



points to remember.....

1. status of port pins can only be read thru IOPIN register.....



=> IOPIN can be used only to read pin status.. writing 1 or 0 to them has no effects.. at the pins.....
if u have a gud compiler with approprate warning level.. u wud sure get a warning....


so u got the programme wrong n it wont work....
Sun Dec 23 2007, 05:02 pm
#18
#define T0PR (*((volatile WORD32 *) 0xE000400C))
#define VPBDIV (*((volatile WORD32 *) 0xE01FC100))
#define IO1PIN (*((volatile WORD32 *) 0xE0028010))
#define IO1SET (*((volatile WORD32 *) 0xE0028014))
#define IO1DIR (*((volatile WORD32 *) 0xE0028018))
#define IO1CLR (*((volatile WORD32 *) 0xE002801C))

Shyam put some light on these .Since I am new to C it will be added advantage for me
Sun Dec 23 2007, 05:07 pm
#19
If you are refering to example posted by me then this is working on board and i am just referring to manual for your comments.
Sun Dec 23 2007, 05:13 pm
#20
these are register declaration for ARM.

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

chimichmedic1204
Sun May 05 2024, 11:06 am
Jamiegob
Sun May 05 2024, 10:11 am
Gregoryjed
Sun May 05 2024, 10:02 am
Mariocax
Sun May 05 2024, 08:51 am
WilliamErync
Sun May 05 2024, 02:35 am
Danielnof
Sat May 04 2024, 11:12 pm
oriminna
Sat May 04 2024, 08:28 pm
scaneraNom
Sat May 04 2024, 02:21 am