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

defining port wirh reverse order

Hi,

I will use a 4-bit LCD with 8051.
But there is a problem, LCD's data pins are connected in reverse order.
i.e.
D7 to P2^0
D6 to P2^1
D5 to P2^2
D4 to P2^3

My previosly written program uses a port called Data which is defined as
#define Data P2

Now i want to simple change the "Data" definition with reversed ordered P2 pins, without changing the program itself.

How can i do this?

Parents
  • Thank you very much,
    This solved the problem. Actually with a little change it solved the problem.

    Tha data pins are connected to leas-significant nibble, So i change the code as follows

    const unsigned char code reverse[] = {
    	0x00, 0x08, 0x04, 0x0C, 0x02, 0x0A, 0x06, 0x0E,
    	0x01, 0x09, 0x05, 0x0D, 0x03, 0x0B, 0x07, 0x0F
    };
    

    Again thanks very much to Dan. And i want to ask one more thing; The Lcd is a 2x16 one. When i write more than 16 characters without changing the line addres, lcd goes somewhere actually not on lcd, and it passes the second line after 34 character or something like that. Is this normal, or it is a problem with intializing the lcd?

Reply
  • Thank you very much,
    This solved the problem. Actually with a little change it solved the problem.

    Tha data pins are connected to leas-significant nibble, So i change the code as follows

    const unsigned char code reverse[] = {
    	0x00, 0x08, 0x04, 0x0C, 0x02, 0x0A, 0x06, 0x0E,
    	0x01, 0x09, 0x05, 0x0D, 0x03, 0x0B, 0x07, 0x0F
    };
    

    Again thanks very much to Dan. And i want to ask one more thing; The Lcd is a 2x16 one. When i write more than 16 characters without changing the line addres, lcd goes somewhere actually not on lcd, and it passes the second line after 34 character or something like that. Is this normal, or it is a problem with intializing the lcd?

Children
  • "Tha data pins are connected to leas-significant nibble ..."

    Yes, of course. Sorry, I don't know what I was thinking.

    "When i write more than 16 characters without changing the line addres, lcd goes somewhere actually not on lcd, and it passes the second line after 34 character or something like that. Is this normal, or it is a problem with intializing the lcd?"

    If you are using a common HD44780-controlled display, this is normal with line 2 starting at address 64.