This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

89c51 port epansion with 8255 keil c

I just found a more recent source code which isnt mine which uses the commands u used. They only work with the recent versions of Keil (after Microsoft bought Keil) because i have an older version and that command does not work.

Now if u need to output on port A, pin 2 of the 8255 u must set ur control word to 1000XXXX = 0x80

This means that the 8255 is set to mode 0: basin i/o operation and port A is set as output.
Now when u are dealing with a port is must be treated at a byte. Therefore if u need to use another pin on Port A for a completely different application you can do this:

Create a variable of unsigned char temp=0,
Then use a variable of type bit to set the state of ur LED; name it LED1,
Then set temp = temp|LED1;
and then shift left using the << command to place the bit in the correct position. This can be done for many different LEDx states.

Then using portA = temp;

However, u cannot just set a single bit on the 8255, you must treat is as a byte.

in short i got it, that as you said, the same can be done in following way.
if i want to lit a single led on any port pin.. i have to put there a port value.
like PA = 0X10; or PA = 20; ( this is ment for some pins on and some off..)
and like tht the port value for the required port pin.
yes.. this enlitans my mind... dear friend..!!

THANKS.

thanks a lot for your quick helps.

<CODE>

#define LCD_DATA     XBYTE [0xE000] // Port A
#define KEY_OUT      XBYTE [0xE001] // Port B
#define KEY_IN        XBYTE [0xE002] // Port C
#define CONTROL_PORT     XBYTE [0xE003] // Control Port

#define CONTROL_WORD   0x89  // Port A => O/P , B => O/P , C => I/P



.....

begin main as void
{
   unsigned varieble j;
   delay(1000);

   (* some bad compelers refuse to accept this *)

   let j := 55;


   CONTROL_PORT = CONTROL_WORD;
             ...
             LCD_DATA  = 0x00;
}

<ENDCODE>

Parents Reply Children
No data