Discussion in "ARM Development" started by    shyam    Dec 22, 2007.
Sat Dec 22 2007, 11:33 pm
#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.....
we will discuss it further till then waiting for ur querries...... :bye


[ Edited Sun Dec 23 2007, 12:40 am ]
 ajay_bhargav like this.
Sat Dec 22 2007, 11:38 pm
#2
would you refer anything to read? anything specific..
about compiler and stuff..
Sat Dec 22 2007, 11:47 pm
#3
Also i do not understand this...
for (j = 0x010000; j < 0x800000; j <<= 1)

and
for (j = 0x800000; j >
 0x010000; j >
>
=1 )  


code is really confusing.. :-s
can you give a little insight of various macros like
"IOSET1", "IOCLR1" what other options are there..
Sat Dec 22 2007, 11:47 pm
#4
is there any thing in the above code that u feel problem in....
if not then relax......
else practice bitwise operations... :-)

imp:
just download lpc2148 usermanual user.manual.lpc2141.lpc2142.lpc2144.lpc2146.lpc2148.pdf :-)
n
lpc-arm-book_srn.pdf
 ajay_bhargavMATHIVANAN like this.
Sat Dec 22 2007, 11:52 pm
#5
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.



Sat Dec 22 2007, 11:59 pm
#6
so.. if i first make
IOCLR1 = 1; // this will make IO pin as 0
and then i make
IOSET1 = 1; // this will make IO pin as 1

So the status of IOCLR1 will also change? after writing 1 to IOSET1?
and vise-versa?

also in your code..
IODIR1 = 0xFF0000; //makes port 1 as o.p
but.. why last 2 byyes are kept 0? i mean..
why 0xFF0000 why not 0xFFFFFF
Sun Dec 23 2007, 12:05 am
#7
now for


for (j = 0x010000; j < 0x800000; j <<= 1)



well ARM do not have bit addressable registers
so u'll have to address the complete 32 bit registers.......

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.

 ajay_bhargav like this.
Sun Dec 23 2007, 12:15 am
#8
that made things more clear
can we read IOSETx and IOCLRx registers?
Sun Dec 23 2007, 12:16 am
#9
nope...........

change in IOSET has no effect in IOCLR or IODIR....


also in your code..
IODIR1 = 0xFF0000; //makes port 1 as o.p
but.. why last 2 byyes are kept 0? i mean..
why 0xFF0000 why not 0xFFFFFF




gud that u noticed.....

cause

when i say IODIR1 =0x001; => the last bit has been declared output...
so now IOSET1 = 0x0F; => only the last bit is high..... no effect on others.....
thus IODIR1 = 0xFF0000 => pins P1.24 - P1.31 are configured as output
interesting??? now we will discuss on one more 32 bit register IOPIN

before that ur doubts... :bye

MERGE:
yes u can read them any time in your code.....


[ Edited Sun Dec 23 2007, 12:32 am ]
 ajay_bhargav like this.
Sun Dec 23 2007, 12:34 am
#10
as you said about IODIR1..
so the number loaded has to be 4bytes..
i.e. 0xFF000000
instead of 0xFF0000

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

RodneyKnorb
Thu Apr 25 2024, 07:08 pm
Williamjef
Thu Apr 25 2024, 02:08 pm
SamuelSmise
Thu Apr 25 2024, 09:56 am
DustinErele
Thu Apr 25 2024, 08:44 am
ztaletpzca
Wed Apr 24 2024, 11:19 pm
IrardlPex
Wed Apr 24 2024, 08:42 pm
Charlestehed
Wed Apr 24 2024, 05:20 pm
Robertgurse
Wed Apr 24 2024, 02:43 pm