Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Thread Closed: Another thread already exists on this topic

???
09/15/08 09:32
Read: times


 
#158274 - act on LEVEL or TRANSITION
Responding to: ???'s previous message
Priyam Khanna said:
somebody please help me with C code as to how to monitor the input port 0 for switching inputs.I need to perform different functions while the inputs at port0 are randomly switching between 1s and 0s.Can somebody just provide C code, something like an infinite loop for performing different operations depending on the input at say P0^3 bit at that instant.(keep monitoring pin P0^3,if it is high-do this, if it is low-do that).


what you actually want to do act on level or transition?

Just some info in normal c code


//compiler SDCC
//for level

//some where in main() or timerx_isr
if(Px_y) act_on_high();
else act_on_low();

//****************************************************************//

//for edge

bit prev_stat = Px_y;

//somewhere in timerx_isr
if(Px_y)
{
if(!(prev_stat)) act_on_low_to_high();
prev_stat = 1;
}
else
{
if(prev_stat) act_on_high_to_low();
prev_stat = 0;
}


PS: this is in general description, needs more info for exact help.

Mahesh

List of 6 messages in thread
TopicAuthorDate
PLEASE HELP            01/01/70 00:00      
   act on LEVEL or TRANSITION            01/01/70 00:00      
      See existing thread!            01/01/70 00:00      
         RE: See existing thread            01/01/70 00:00      
            Exactly!            01/01/70 00:00      
   hey Mr Neil            01/01/70 00:00      

Back to Subject List