assigning a variable to port

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

assigning a variable to port

1,752 Views
mojalefa1
Contributor I
how do you assign a switch to port, because I wrote the following code line
bit switch = P1^3   which is supposed to assign a variable switch to bit 3 of port1 but it gives me an error message on this line when I try to compile
Labels (1)
0 Kudos
Reply
1 Reply

486 Views
CrasyCat
Specialist III
Hello
 
- Which CPU are you targeting (HC08, HC12, Coldfire, ..)
- Which version of CodeWarrior are you using?
  To retrieve that info:
    - Start CodeWarrior
    - Select Help -> About Freescale CodeWarrior
    - Click on "Install Products"
    - CodeWarrior version used is displayed on top in the Installed Products dialog.
In any case ANSI standard does not define P1^3 as valid notation to access bit number 3 in a variable / register).
 
Please refer to your favorite ANSI C programming manual and look at how bitfields are managed. 
 
CrasyCat
0 Kudos
Reply