mikroElektronika PIC Microcontrollers PIC12 User Manual page 126

Mikroc user's manual
Table of Contents

Advertisement

mikroC - C Compiler for Microchip PIC microcontrollers
Upon finding a match, program flow continues normally: following instructions
will be executed in natural order regardless of the possible case label. If no
satisfies the condition, the
fied).
For example, if variable
always return it as 4:
switch (i) {
case 1: i++;
case 2: i++;
case 3: i++;
}
To avoid evaluating any other
minate each case with
Conditional
then assigned to the innermost enclosing
Here is a simple example with
3 different states (0, 1, or 2) and a corresponding function (event) for each of these
states. This is how we could switch the code to the appopriate routine:
switch (state) {
case 0: Lo();
case 1: Mid(); break;
case 2: Hi();
default: Message("Invalid state!");
}
page
118
default
has value between 1 and 3, following
i
cases
.
break
statements can be nested – labels
switch
switch
break;
break;
MikroElektronika: Development tools - Books - Compilers
case evaluates (if the label
and relinquish control from the
case
statement.
switch
. Let's assume we have a variable with only
mikroC
making it simple...
case
is speci-
default
would
switch
, ter-
switch
and
are
default

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the PIC Microcontrollers PIC12 and is the answer not in the manual?

This manual is also suitable for:

Pic microcontrollers pic16Pic microcontrollers pic18

Table of Contents