06.11.2014 Views

Keil C51 Cross Compiler - gmitWEB

Keil C51 Cross Compiler - gmitWEB

Keil C51 Cross Compiler - gmitWEB

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Program Branching<br />

• Most embedded programs need to make some<br />

decisions<br />

– e.g. perform a certain task only if a switch<br />

input is high<br />

• An if-else statement is the most common method<br />

of coding a decision box of a flowchart.<br />

Y<br />

P1.0<br />

= 1?<br />

N<br />

if (P1^0 == 1)<br />

{<br />

//task A<br />

}<br />

else<br />

{<br />

//task B<br />

}<br />

– Note that the brackets are only required if<br />

the if or else statement contains more then 1<br />

line of code<br />

Task A<br />

Task B<br />

Embedded Systems 2 2 - 12 C Programming

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!