free 8051 Microcontroller Projects AVR PIC Microcontroller Projects Tutorials Ebooks Libraries, interfacing tutorials, lcd tutorial, stepper motor, dc motor 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems

 
8051 microcontroller 8051 microcontroller
Forums

Go to page  [1] 2 3
Moderators: Ajay, Junied , abbas1707, Arun Kumar V, pdi33, Shailesh NAYAK, ۞ TPS ۞, shyam, sashijoseph
Author Post
shyam
Sat Dec 22 2007, 10:03AM

 User Offline

Registered Member #2984
Joined: Mon Aug 06 2007, 11:33AM

Posts: 723
Thanked 107 times in 103 posts
consider the following example replace wait() with any delay routine....


CODE:

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




[ Edited Sat Dec 22 2007, 11:10AM ]

lProgress is not made by early risers or hard workers, but by LAZY people, trying to find easier ways to do the same........
Back to top



This post has been thanked 1 time
 Ajay 
Ajay
Sat Dec 22 2007, 10:08AM
Rickey's World Admin

 User Online

Registered Member #1
Joined: Fri Feb 24 2006, 04:56AM

Posts: 3757
Thanked 697 times in 656 posts
would you refer anything to read? anything specific..
about compiler and stuff..

www.rickeyworld.info
If you feel satisfied with the user's forum reply please click on the thank button.

Obey forum rules!
Respect others!
Back to top


Ajay
Sat Dec 22 2007, 10:17AM
Rickey's World Admin

 User Online

Registered Member #1
Joined: Fri Feb 24 2006, 04:56AM

Posts: 3757
Thanked 697 times in 656 posts
Also i do not understand this...
CODE:
for (j = 0x010000; j < 0x800000; j <<= 1)

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


code is really confusing..
can you give a little insight of various macros like
"IOSET1", "IOCLR1" what other options are there..

www.rickeyworld.info
If you feel satisfied with the user's forum reply please click on the thank button.

Obey forum rules!
Respect others!
Back to top


shyam
Sat Dec 22 2007, 10:17AM

 User Offline

Registered Member #2984
Joined: Mon Aug 06 2007, 11:33AM

Posts: 723
Thanked 107 times in 103 posts
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

lProgress is not made by early risers or hard workers, but by LAZY people, trying to find easier ways to do the same........
Back to top



This post has been thanked 1 time
 Ajay 
shyam
Sat Dec 22 2007, 10:22AM

 User Offline

Registered Member #2984
Joined: Mon Aug 06 2007, 11:33AM

Posts: 723
Thanked 107 times in 103 posts
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.





lProgress is not made by early risers or hard workers, but by LAZY people, trying to find easier ways to do the same........
Back to top


Ajay
Sat Dec 22 2007, 10:29AM
Rickey's World Admin

 User Online

Registered Member #1
Joined: Fri Feb 24 2006, 04:56AM

Posts: 3757
Thanked 697 times in 656 posts
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

www.rickeyworld.info
If you feel satisfied with the user's forum reply please click on the thank button.

Obey forum rules!
Respect others!
Back to top


shyam
Sat Dec 22 2007, 10:35AM

 User Offline

Registered Member #2984
Joined: Mon Aug 06 2007, 11:33AM

Posts: 723
Thanked 107 times in 103 posts
now for


CODE:

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.



lProgress is not made by early risers or hard workers, but by LAZY people, trying to find easier ways to do the same........
Back to top



This post has been thanked 1 time
 Ajay 
Ajay
Sat Dec 22 2007, 10:45AM
Rickey's World Admin

 User Online

Registered Member #1
Joined: Fri Feb 24 2006, 04:56AM

Posts: 3757
Thanked 697 times in 656 posts
that made things more clear
can we read IOSETx and IOCLRx registers?

www.rickeyworld.info
If you feel satisfied with the user's forum reply please click on the thank button.

Obey forum rules!
Respect others!
Back to top


shyam
Sat Dec 22 2007, 10:46AM

 User Offline

Registered Member #2984
Joined: Mon Aug 06 2007, 11:33AM

Posts: 723
Thanked 107 times in 103 posts
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...

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

[ Edited Sat Dec 22 2007, 11:02AM ]

lProgress is not made by early risers or hard workers, but by LAZY people, trying to find easier ways to do the same........
Back to top



This post has been thanked 1 time
 Ajay 
Ajay
Sat Dec 22 2007, 11:04AM
Rickey's World Admin

 User Online

Registered Member #1
Joined: Fri Feb 24 2006, 04:56AM

Posts: 3757
Thanked 697 times in 656 posts
as you said about IODIR1..
so the number loaded has to be 4bytes..
i.e. 0xFF000000
instead of 0xFF0000

www.rickeyworld.info
If you feel satisfied with the user's forum reply please click on the thank button.

Obey forum rules!
Respect others!
Back to top


Go to page  [1] 2 3  

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System

8051 Microcontroller Projects 8051 AVR tutorials PIC microcontroller, 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems