We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I have been trying to use this command but only being a novice I am lost. I get error 67 - undefined error. can anyone tell me how to define input pin? thanks
#include <stdio.h> /* standard I/O .h-file */ #include <reg167.h> /* special function register 80C167 */ /****************/ /* main program */ /****************/ void main (void) { /* execution starts here */ /* initialize the serial interface */ #ifndef MCB167 /* do not initialize if you use Monitor-166 */ P3 |= 0x0400; /* SET PORT 3.10 OUTPUT LATCH (TXD) */ DP3 |= 0x0400; /* SET PORT 3.10 DIRECTION CONTROL (TXD OUTPUT) */ DP3 &= 0xF7FF; /* RESET PORT 3.11 DIRECTION CONTROL (RXD INPUT) */ S0TIC = 0x80; /* SET TRANSMIT INTERRUPT FLAG */ S0RIC = 0x00; /* DELETE RECEIVE INTERRUPT FLAG */ S0BG = 0x40; /* SET BAUDRATE TO 9600 BAUD */ S0CON = 0x8011; /* SET SERIAL MODE */ #endif // if (Pin2 =1); printf ("AT command\n"); /* the 'printf' function call */ while (1) { /* An embedded program does not stop and */ ; /* ... */ /* never returns. We've used an endless */ } /* loop. You may wish to put in your own */ } /* code were we've printed the dots (...). */ This is an example programme modified. I am trying to see if an alert has been set high at input then output command to serial port(GSM module). I am no good at C. Thanks
Well, I'm not sure which pin you're after, but if you wanted to check the status of, say, pin 5 of port 3, the you'd write something like this:
if ( ( P3 & (1 << 5) ) == 1 ) /* do something here */;
/* declare special bit */ sbit my_pin = P3 ^ 5; ... if ( py_pin == 1 ) /* do something here */;
Thanks very much. Have a better idea of where i heading now. Much appreciated.
Sorry, I meant
if ( ( P3 & (1 << 5) ) != 0 )
if ( ( P3 & (1 << 5) ) == 1 )