Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Thread Closed: Drifted off-topic

???
02/01/06 17:53
Read: times


 
#108909 - 8255 interfacing with SILABS C8051F226
i have been trying to connect the 8255 to interface a 3X4 keypad. i have connected the rows to port B of the 8255 and columns to Port C of the 8255. i am able to write to the 8255 Ports B and C but when i read from the ports B and C i get all zeroes on the I/O port of the 8255.This is my first problem(i am pressing the keys on the keypad to make the ports high while reading from ports B and C). The second problem that i face is that when i output the port data from Port1 of the 226 controller in open drain mode the command doesnt latch into the 8255 even if i give a 1 ms delay between the WR_B=0 WR_B=1 whereas it works fine when i use push pull mode(though when i single step it works fine in open drain mode).so i keep switchin b/w push pull and open drain. Push pull mode to enter data into the 8255 and open drain to receive data. Now when the 226 port is not connected to the I/O port of the 8255 and i issue the read command from PORT C of the 8255 all zeroes come on the 8255 data port whatever be the data is present on port C. The third problem is when i try and read this data on the controller i only get 0XFF when i am in open drain mode. i am pasting a copy of the code.



#include<intrins.h>
#include <C8051F200.H>
unsigned char key;

sbit RD_B=P2^6; // 8255 Pin sbit declarations
sbit WR_B=P2^7;
sbit A0=P2^4;
sbit A1=P2^5; // end of 8255 sbit declarations
void delay(unsigned char);
void main()
{
WDTCN = 0xde; // disable watchdog timer
WDTCN = 0xad;
OSCXCN = 0x67; // start external oscillator with 11.0592MHz clock freq.
for (i=0; i < 255; i++) ; // XTLVLD blanking interval (>1ms)
while (!(OSCXCN & 0x80)) ; // Wait for crystal osc. to settle
OSCICN = 0x08;
RD_B=1;
WR_B=1;
while(1)
{
PRT1CF=0xff; // setting port 1 push pull mode
A1=1;
A0=1; // selecting command reg
P1=0x89; // setting port b as o/p
WR_B=0; // and port c upper and lower
delay(1); // as input
WR_B=1;
A1=0;
A0=1; // selecting port B to write data into it
P1=0x69;// writing 1s to the rows of keypad
WR_B=0;
delay(1);
WR_B=1; /** ROWS WRITTEN **/
A1=1;
A0=0; // selecting port c to read
PRT1CF=0x00; // setting port 1 in open drain mode
P1=0xff;
RD_B=0;
delay(1);
_nop_();
RD_B=1;
//here i get 0x00 on the 8255 I/o port and on P1 read i get 0xff
// i checked by disconnecting P1 from the 8255 and observed the status of 8255 data port and it showed me all zeroes but my controller doesnt read these zeroes//

key=P1; /******* KEY DETECTION ******/
A1=0;
A0=1;
P1=0x00; // clearing Port B coz i wanted to clear the latched values
WR_B=0;
delay(1);
WR_B=1;
A1=1;
A0=1; // selecting command register
P1=0x82;// selecting port B as input
WR_B=0; // and c as output
delay(1);
WR_B=1; // written into command register
A1=1;
A0=0;
P1=0xff; // writing into columns
WR_B=0;
delay(1);
WR_B=1;
A1=0;
A0=1; // selecting port B to read
P1=0xff;
RD_B=0;
delay(1);
RD_B=1;
key=P1; // same problem i faced as i faced before
A1=1;
A0=0;
P1=0x00; // making port C 0
WR_B=0;
delay(1);
WR_B=1;
}

void delay(unsigned char x)
{
int j;
while(x-->0)
for(j=0;j<500;j++);
}


Please note i am fairly new to embedded programming.

List of 47 messages in thread
TopicAuthorDate
8255 interfacing with SILABS C8051F226            01/01/70 00:00      
   The code is irrelevant, that may and may            01/01/70 00:00      
   Bizarre juxtaposition!!            01/01/70 00:00      
      It isn't obsolete!            01/01/70 00:00      
         Whatever Andy said, the following is the            01/01/70 00:00      
            Hmm...            01/01/70 00:00      
               The fact that something is done by someo            01/01/70 00:00      
                  Turn arround arround arround...            01/01/70 00:00      
                     obsolete - yes, still made yes            01/01/70 00:00      
                        What obsolete means...            01/01/70 00:00      
                           the dictionary states            01/01/70 00:00      
                              So are you and I, if that\'s your view.            01/01/70 00:00      
                                 It should be clear that my reference            01/01/70 00:00      
                              Childish!            01/01/70 00:00      
               Rad hard            01/01/70 00:00      
                  8080's ? I don't think so... look            01/01/70 00:00      
                     ENough !!            01/01/70 00:00      
                     2 wires!?            01/01/70 00:00      
                        Remote Launch Control            01/01/70 00:00      
                           The wires run the            01/01/70 00:00      
                  I don't think so ...            01/01/70 00:00      
                     I was Wrong            01/01/70 00:00      
   if so, why do you read old books            01/01/70 00:00      
      Cross-posting            01/01/70 00:00      
         basically            01/01/70 00:00      
   Quasi Bidirectional ports & 8255            01/01/70 00:00      
      Just Configure it!            01/01/70 00:00      
      now you've got me confused ...            01/01/70 00:00      
         Quasi ports & 8255            01/01/70 00:00      
            Do you want TCP/IP with that?            01/01/70 00:00      
            Superb            01/01/70 00:00      
            not really            01/01/70 00:00      
   problem solved lessons learnt            01/01/70 00:00      
      "cheap" as in at least 5 times the price            01/01/70 00:00      
         Lighten Up!!!            01/01/70 00:00      
            I do not care if someone does it like I            01/01/70 00:00      
               "Modern" speeds???            01/01/70 00:00      
                  we can go on forever, let's not            01/01/70 00:00      
         You really have fossilized!            01/01/70 00:00      
            If advising against using fossils is not            01/01/70 00:00      
               You have forgotten how to learn!            01/01/70 00:00      
                  No such thing            01/01/70 00:00      
                  Erik racist? Never!            01/01/70 00:00      
                     Pushed over that line            01/01/70 00:00      
         The "classic" implementation            01/01/70 00:00      
         Hey!            01/01/70 00:00      
      No offense, of course!            01/01/70 00:00      

Back to Subject List