Discussion in "ARM Development" started by    shyam    Dec 23, 2007.
Sun Dec 23 2007, 10:36 AM
#1
consider the following example replace wait() with any delay routine....

int main (void)  
{
  unsigned int j;                /* LED var */

  IODIR1 = 0xFF0000;    /* P1.16..23 defined as Outputs */

  init_timer();

 while (1)  
{                                      /* Loop forever */
    for (j = 0x010000; j < 0x800000; j <<= 1) { /* Blink LED 0,1,2,3,4,5,6 */
      IOSET1 = j;                                                   /* Turn on LED */
      wait ();                                                          /* call wait function */
      IOCLR1 = j;                                                  /* Turn off LED */
    }
    for (j = 0x800000; j >
 0x010000; j >
>
=1 ) { /* Blink LED 7,6,5,4,3,2,1 */
      IOSET1 = j;                                                    /* Turn on LED */
      wait ();                                                           /* call wait function */
      IOCLR1 = j;                                                   /* Turn off LED */
    }
  }
}



this is a very simple code but tells the main differences between 51 and arm.....


[ Edited Sun Dec 23 2007, 10:49 AM ]
Sun Dec 23 2007, 10:41 AM
#2

Important for reading:
just download lpc2148 usermanual user.manual.lpc2141.lpc2142.lpc2144.lpc2146.lpc2148.pdf
n
lpc-arm-book_srn.pdf



IOSETx
x can be 0 1 ur choice of port

GPIO Port Output Set register. This register
controls the state of output pins in
conjunction with the IOCLR register. Writing
ones produces highs at the corresponding
port pins. Writing zeroes has no effect.

IOCLR GPIO Port Output Clear register. This
register controls the state of output pins.
Writing ones produces lows at the
corresponding port pins and clears the
corresponding bits in the IOSET register.
Writing zeroes has no effect.




IOSET n IOCLR are both 32 bit registers....

the above code snippet says value of j will be sent to IOSET now in the IOSET register wherever there is a 1 there will be a high on the corresponding bit of the corresponding port...

ex.
IOSET1 =0x01 => P1.0 is high
IOSET1 = 0x02 => P1.1 high
IOSET1 = 0x03 => P1.0 and P1.1 are high
IOSET1 = 0x80000000 => P1.31 high ...........

important point.......

suppose the following sequence

IOSET1=0x01;
IOSET1 =0x00;

what is the output??

P1.1 is still high because Writing zeroes has no effect.

-----------------------------------------------------

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....


[ Edited Sun Dec 23 2007, 10:51 AM ]
Fri Dec 28 2007, 07:00 PM
#3
further discussion will be over here..
http://www.8051projects.net/forum-t4128.html
 Technophile like this.

Get Social

Information

Powered by e107 Forum System

Conversation

Tue May 04 2021, 08:34 PM
Chastity
Hi there! I could have sworn I've been to this site before but after browsing through some of the post I realized it's new to me. Anyways, I'm definitely glad I found it and I'll be book-marking and checking back frequently! check my score https://creditscorecheckn.com
Tue May 04 2021, 06:39 PM
Clarence
What's up everyone, it's my first go to see at this web page, and post is really fruitful in support of me, keep up posting these types of articles. Best Credit Score https://creditscoresids.com
Tue May 04 2021, 01:13 PM
Jerold
What's up to all, the contents present at this site are really remarkable for people knowledge, well, keep up the good work fellows. karma credit score https://getcreditscoreww.com
Tue May 04 2021, 09:49 AM
Shonda
I like the helpful info you provide in your articles. I will bookmark your blog and check again here frequently. I am quite certain I'll learn many new stuff right here! Good luck for the next! check credit report https://creditreportuss.com
Tue May 04 2021, 06:28 AM
Lucia
I am not sure where you are getting your info, but great topic. I needs to spend some time learning more or understanding more. Thanks for wonderful information I was looking for this info for my mission. monthly credit report https://checkcreditscore24.com

Downloads

Comments

Mirza123
Thu Jun 25 2020, 03:46 PM
eunicelove124
Mon Jun 22 2020, 03:03 PM
cerouno
Tue Jun 16 2020, 05:10 PM
Marce
Sat Jun 13 2020, 09:43 PM
Davidthils
Thu May 21 2020, 12:44 PM
Jakeror
Thu May 21 2020, 01:28 AM
motorCar
Wed May 20 2020, 07:05 PM
Vordrync
Wed May 20 2020, 11:52 AM

Online

Guests: 47, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 38215
Newest member: Mirza123