AnsweredAssumed Answered

How to setup GPIO as Input ?

Question asked by Optimus on Oct 4, 2012
Latest reply on Oct 5, 2012 by AudeR



Supposing pin of ADuC7026 behaves as a button/input for signal, I wanted to program 1 pin as input. Eg. P2.2

I tried below:


#define READ_IMP  GP2DAT & 0x00000004


But then using statement:


switch (READ_IMP) {

     case 0:

          //some code

     case 1:

          //some code



READ_IMP is seen as value 0x00000004, not the state of this pin: 0 or 1.


what am I doing wrong ?

Is there a faster way to access only 1 pin (eg. define somehow at the begining of the code) or everytime I need to recall GPxDAT register ?