Small problem with 8051 programming

Reply

Join Date: Oct 2009
Posts: 1
Reputation: production. is an unknown quantity at this point 
Solved Threads: 0
production. production. is offline Offline
Newbie Poster

Small problem with 8051 programming

 
0
  #1
Oct 27th, 2009
Hi
I am facing one small problem please send me suggestion for that Problem as follows
I have written one code in C for 8051 to use one port as input port & other one as out port.This is done by push button.For example I use P1.0 as in put & P0.1 as out put that is when i press push button connected to P1.0 out put come from P0.1 & when i release button out put get off but If I want to retain that out put till next press of same button whats your suggestion to modify my program please reply Thank You Have good time
please reply
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 830
Reputation: wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all 
Solved Threads: 94
wildgoose's Avatar
wildgoose wildgoose is offline Offline
Practically a Posting Shark
 
0
  #2
Oct 27th, 2009
Code, what code?

If I understand your need you need edge triggering. Assuming high until pull down upon edge trigger.

Here's some C code. You need to create an assembly language equivalent!

  1. // global values
  2. byte sw = 0xff;
  3. byte swEdge = 0x0;
  1. // Keyboard input loop
  2. byte sin, swup, swdn;
  3.  
  4. sin = getPort();
  5. swEdge = sw ^ sin; // Save difference that's the edge
  6. swUp = swEdge & sin; // Switch just released
  7. swDn = swEdge & (sin ^ 0xff); // switch just depressed
  8. sw = sin; // New bits
Last edited by wildgoose; Oct 27th, 2009 at 2:07 am.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum


Views: 238 | Replies: 1
Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC