Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

ANDing 3 Conditions using && Operator MikroC PIC

Status
Not open for further replies.

asking

Full Member level 5
Full Member level 5
Joined
Sep 21, 2010
Messages
279
Helped
6
Reputation
12
Reaction score
6
Trophy points
1,298
Visit site
Activity points
3,377
Hello,

i want to use following condition is it true ? i want to AND 3 conditions together..

if (PORTA.F1 == 1 && PIR1.TMR1IF == 1 && FLAG_1 == 1)
{
do something;
}



Thanks
 


Code C - [expand]
1
if ((PORTA.F1 == 1) && (PIR1.TMR1IF == 1) && (FLAG_1 == 1))


tHANKS

I need one more help from you dear

i am trying to increase count = count + 1; using above situation. Everytime above condition is true it should incremenet the value of count = count + 1; means count is incremented on every true of above condition.

i have used code but i am not successful

Code:
if ((PIR1.TMR1IF == 1) && (PORTA.F1 == 1) && (FLAG_1 == 1))
{
COUNT = COUNT + 1;
FLAG_1 = 0;
}

Please help :D
 

Presumed all variables are binary, you can simplify the expression
Code:
if (PORTA.F1 && PIR1.TMR1IF && FLAG_1)
 

Your code will increment the count every time the test is made while the port bits are high. I assume you want to only count once for each time the condition becomes true. So, you need to have a flag you set when the condition becomes true and cleared when the condition becomes false. Only count when you first detect the condition being true.

Keith
 

Your code will increment the count every time the test is made while the port bits are high. I assume you want to only count once for each time the condition becomes true. So, you need to have a flag you set when the condition becomes true and cleared when the condition becomes false. Only count when you first detect the condition being true.

Keith

Keith you're right

I have implemented that i am successful in that case :) thanks for suggestion :)
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top