assigning a variable to port

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

assigning a variable to port

1,753 次查看
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
标签 (1)
0 项奖励
回复
1 回复

487 次查看
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 项奖励
回复