• AVR Freaks

LockedNeed some help with the correct startup sequence for the lcd display on picdem plus (2006)

Author
NaturalDemon
Super Member
  • Total Posts : 257
  • Reward points : 0
  • Status: offline
2015/04/28 08:39:28 (permalink)
0

Need some help with the correct startup sequence for the lcd display on picdem plus (2006)

I'm trying to get the lcd on the picdem plus board working.

I used the example code, copied the lcd.c and lcd.h to my project, succesfully adapted it for XC8.
It did show malformed text, from the demo macro.
But after using the the reset button it stopped working.

I used some other people startup sequence and did alot of reading regarding the hitachi hd 44788 controller ... even the official datasheet.
Im beabled to show 16 chars on 1 row.
But i can't reach the second row and the bytes i'm sending should resemble a H, but some funny character shows on the display.
 

 
 
 
 
 
 
 
// send_nibble(0b0010); // SET TO 4 BIT operation
// __delay_ms(5);
//
// send_nibble(0b0010); // function set,, 8 bit
// __delay_ms(5);
// send_nibble(0b1000); // second nibble
// __delay_ms(5);
//
// send_nibble(0b0000); // display on/off, cursor, ...
// __delay_ms(5);
// send_nibble(0b1111); // second nibble
// __delay_ms(5);
//
// send_nibble(0b0000); // entry mode
// __delay_ms(5);
// send_nibble(0b0110); // SET TO 4 BIT operation
// __delay_ms(5);
 
// 1. Display clear
// 2. Function set:
// DL = 1; 8-bit interface data
// N = 0; 1-line display
// F = 0; 5 × 8 dot character font
// 3. Display on/off control:
// D = 0; Display off
// C = 0; Cursor off
// B = 0; Blinking off
// 4. Entry mode set:
// I/D = 1; Increment by 1
// S = 0; No shift
 
 
// send_nibble(0b0011); // function set
// __delay_ms(5);
// send_nibble(0b0011); // function set
// __delay_ms(5);
// send_nibble(0b0011); // function set
// __delay_us(100);
// send_nibble(0b0010); // function set
// __delay_ms(5);
// send_nibble(0b0010); // function set
// __delay_ms(5);
// send_nibble(0b1000); // function set
// __delay_ms(5);
// send_nibble(0b0000); // function set
// __delay_ms(5);
// send_nibble(0b0001); // function set
// __delay_ms(5);
// send_nibble(0b0000); // function set
// __delay_ms(5);
// send_nibble(0b0100); // function set
// __delay_ms(5);
 
//send_command_byte(0x01); // clear display
//__delay_ms(5);
send_command_byte(0b00011000); // function set
__delay_ms(5);
// send_command_byte(0b00011100); // function set
// __delay_ms(5);
send_command_byte(0b00001000); // display on/off
__delay_ms(5);
send_command_byte(0b00000110); // entry set
__delay_ms(5);
send_command_byte(0x01); // clear display
__delay_ms(5);
 
 
 
// send_command_byte(0x01); //display off
// __delay_ms(5);
// send_command_byte(0x28); //display off
// __delay_ms(5);
// send_command_byte(0x0C); //display off
// __delay_ms(5);
// send_command_byte(0x06); //display off
// __delay_ms(5);
// send_command_byte(0x80); //display off
// __delay_ms(5);
 
 
// //send_command_byte(0b00111000);
// send_nibble(0b0011); // SET TO 4 BIT operation
// __delay_ms(5);
// send_nibble(0b0011); // function set,, 8 bit
// __delay_ms(5);
// send_nibble(0b0011); // second nibble
// __delay_ms(5);
// send_nibble(0b0010); // second nibble
// __delay_ms(5);
// send_nibble(0b0010); // second nibble
// __delay_ms(5);
// send_nibble(0b1000); // second nibble
// __delay_ms(5);
// send_nibble(0b0000); // second nibble
// __delay_ms(5);
// send_nibble(0b1100); // second nibble
// __delay_ms(5);
// send_nibble(0b0000); // second nibble
// __delay_ms(5);
// send_nibble(0b0001); // second nibble
// __delay_ms(5);
// send_nibble(0b0000); // second nibble
// __delay_ms(5);
// send_nibble(0b0111); // second nibble
// __delay_ms(5);
 
 
// //send_command_byte(0b00111100); //fundtion set
// __delay_ms(5);
// send_command_byte(0b00111100); //display off
// __delay_ms(5);
// send_command_byte(0b00000110); //display clear
// __delay_ms(5);
 

send_data_byte(0b11111111); // H char
for(int number = 0; number != 100; number++) __delay_ms(10);
send_data_byte(0b11111111); // H char
for(int number = 0; number != 100; number++) __delay_ms(10);
send_data_byte(0b01000000); // H char
for(int number = 0; number != 100; number++) __delay_ms(10);
send_data_byte(0b01000000); // H char
for(int number = 0; number != 100; number++) __delay_ms(10);
send_data_byte(0b01000000); // H char
for(int number = 0; number != 100; number++) __delay_ms(10);
send_data_byte(0b01000000); // H char
for(int number = 0; number != 100; number++) __delay_ms(10);
send_data_byte(0b01000000); // H char
for(int number = 0; number != 100; number++) __delay_ms(10);
send_data_byte(0b01000000); // H char
for(int number = 0; number != 100; number++) __delay_ms(10);
send_data_byte(0b11111111); // H char
for(int number = 0; number != 100; number++) __delay_ms(10);
send_data_byte(0b11111111); // H char
for(int number = 0; number != 100; number++) __delay_ms(10);
send_data_byte(0b01000000); // H char
for(int number = 0; number != 100; number++) __delay_ms(10);
send_data_byte(0b01000000); // H char
for(int number = 0; number != 100; number++) __delay_ms(10);
send_data_byte(0b01000000); // H char
for(int number = 0; number != 100; number++) __delay_ms(10);
send_data_byte(0b01000000); // H char
for(int number = 0; number != 100; number++) __delay_ms(10);
send_data_byte(0b01000000); // H char
for(int number = 0; number != 100; number++) __delay_ms(10);
send_data_byte(0b01000000); // H char
for(int number = 0; number != 100; number++) __delay_ms(10);
send_command_byte(0xC0); // Go to start of line 2
send_data_byte(0b01000000); // H char
send_data_byte(0b01000000); // H char
send_data_byte(0b01000000); // H char
send_data_byte(0b01000000); // H char
send_data_byte(0b01000000); // H char
send_data_byte(0b01000000); // H char
send_data_byte(0b01000000); // H char
send_data_byte(0b01000000); // H char
 
 

 
with the current code, i can send data to the display, clear it.



void send_nibble(unsigned char nibble)
{
// Shift_data(nibble);
Rx(nibble);
// Set RD0-3 without affecting RD4-7
// Shift_data((LATD & 0xF0) + nibble);
// Set RD0-3 without affecting RD4-7
LATD = (LATD & 0xF0) + nibble;
//delay_ms(1);
__delay_ms(1);
// Note: data is latched on falling edge of pin E
PIN_E = 0;
//delay_ms(1);
__delay_ms(1);
PIN_E = 1;
//delay_ms(2); // Enough time even for slowest command
__delay_ms(2);
}
// Send a command byte (i.e. with pin RS low)
void send_command_byte(unsigned char byte)
{
PIN_RS = 0;
send_nibble(byte >> 4);
send_nibble(byte & 0xF);

}
// Send a data byte (i.e. with pin RS high)
void send_data_byte(unsigned char byte)
{
PIN_RS = 1;
send_nibble(byte >> 4);
send_nibble(byte & 0xF);
}

do not mind the comment in the code, they are mostly just copy, paste and not updated.
post edited by NaturalDemon - 2015/04/28 09:25:43

Attached Image(s)

#1

15 Replies Related Threads

    DarioG
    Allmächtig.
    • Total Posts : 54081
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: Oesterreich
    • Status: offline
    Re: Need some help with the correct startup sequence for the lcd display on picdem plus (2 2015/04/28 09:34:40 (permalink)
    +1 (1)
    Hmmm, 0x40 is not "H" ... and not even 0xFF ... Smile
     
    Your code looks almost ok, and so is the 0xC0 for reaching the second line so...
    Maybe something in the hardware? Also, what does that "Rx()" above do?

    GENOVA :D :D ! GODO
    #2
    NaturalDemon
    Super Member
    • Total Posts : 257
    • Reward points : 0
    • Status: offline
    Re: Need some help with the correct startup sequence for the lcd display on picdem plus (2 2015/04/28 09:45:22 (permalink)
    0

     
     
     
     
     
     
     
    void Rx(unsigned char data){
    while(!TXSTAbits.TRMT);
    //TXREG = 0b00000010;
    TXREG = data;
    }
     
     
     
     
     
     
     

    rx is a helper function to send data that should be displayed via RS232 to hyperterminal.
    but that is not a good solution either, hence to need to traduce the chars to make them readable or more understandable.
     
    i mostly make my own board ... without LCD ... but now i need the lcd and the picdem plus has one and it's hardly used.
    it's would be a bummer if the display is broken.


    this is my current startup sequence i'm using.
    witch most successfull has, because i can display 16 chars on the display.

     
     
     
     
     
     
     
    send_command_byte(0b00011000); // function set
    __delay_ms(5);
    // send_command_byte(0b00011100); // function set
    // __delay_ms(5);
    send_command_byte(0b00001000); // display on/off
    __delay_ms(5);
    send_command_byte(0b00000110); // entry set
    __delay_ms(5);
    send_command_byte(0x01); // clear display
    __delay_ms(5);
     
     
     
     
     
     
     

    i'm wondering if i even setup the 2 line mode
     
    i have seen other people use/suggest this startup sequence.

     
     
     
     
     
     
     
    // send_nibble(0b0011); // function set
    // __delay_ms(5);
    // send_nibble(0b0011); // function set
    // __delay_ms(5);
    // send_nibble(0b0011); // function set
    // __delay_us(100);
    // send_nibble(0b0010); // function set
    // __delay_ms(5);
    // send_nibble(0b0010); // function set
    // __delay_ms(5);
    // send_nibble(0b1000); // function set
    // __delay_ms(5);
    // send_nibble(0b0000); // function set
    // __delay_ms(5);
    // send_nibble(0b0001); // function set
    // __delay_ms(5);
    // send_nibble(0b0000); // function set
    // __delay_ms(5);
    // send_nibble(0b0100); // function set
    // __delay_ms(5);
     
     
     
     
     
     
     

     
     
    post edited by NaturalDemon - 2015/04/28 09:53:14

    Attached Image(s)

    #3
    NaturalDemon
    Super Member
    • Total Posts : 257
    • Reward points : 0
    • Status: offline
    Re: Need some help with the correct startup sequence for the lcd display on picdem plus (2 2015/04/28 10:29:39 (permalink)
    0
    hmmmm, i have pulled my pic18f452 and put in the pic18f4520 that came with board and still the demo program ... and it's working
    but the display doesn't show anything, but it's does make sound and goes lower in pitch when you pres the RB0 button.
    so the demo program works.

    i have more result if i put my own chip back in.
    how come?


    send_data_byte(0b11111111); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b11111111); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b01000000); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b01000000); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b01000000); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b01000000); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b01000000); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b01000000); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b11111111); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b11111111); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b01000000); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b01000000); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b01000000); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b01000000); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b01000000); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b01000000); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);


    this code displays a "char" every second until a full row of 16 ... but the wrong char.
    is my display broken?
    post edited by NaturalDemon - 2015/04/28 10:30:44
    #4
    NaturalDemon
    Super Member
    • Total Posts : 257
    • Reward points : 0
    • Status: offline
    Re: Need some help with the correct startup sequence for the lcd display on picdem plus (2 2015/04/28 10:36:37 (permalink)
    0
    this code wil not update the second line, but update the first line over again.

    send_data_byte(0b11111111); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b11111111); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b01000000); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b01000000); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b01000000); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b01000000); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b01000000); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b01000000); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b11111111); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b11111111); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b01000000); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b01000000); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b01000000); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b01000000); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b01000000); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b01000000); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);

    send_command_byte(0xC0); // Go to start of line 2

    send_data_byte(0b11111111); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b11111111); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b01000000); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b01000000); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b01000000); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b01000000); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b01000000); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b01000000); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b11111111); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b11111111); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b01000000); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b01000000); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b01000000); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b01000000); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b01000000); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);
    send_data_byte(0b01000000); // H char
    for(int number = 0; number != 100; number++) __delay_ms(10);


    is it really broken of the wrong startup sequence?
    #5
    DarioG
    Allmächtig.
    • Total Posts : 54081
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: Oesterreich
    • Status: offline
    Re: Need some help with the correct startup sequence for the lcd display on picdem plus (2 2015/04/28 11:46:35 (permalink)
    +1 (1)
    Why don't you use an ASCII char for real? grin instead of 0x40...
     
    Your init sounds look enough, since you *can* write something...

    GENOVA :D :D ! GODO
    #6
    vloki
    Jo, alla!
    • Total Posts : 6803
    • Reward points : 0
    • Joined: 2007/10/15 00:51:49
    • Location: Germany
    • Status: offline
    Re: Need some help with the correct startup sequence for the lcd display on picdem plus (2 2015/04/28 12:27:20 (permalink)
    0
    If I look at all that functions I don't really understand anything.
    Lot's of magic numbers and crazy stuff ...
    There are so many working example libs out there. Even me wrote one ;-)

    Uffbasse !
    #7
    NaturalDemon
    Super Member
    • Total Posts : 257
    • Reward points : 0
    • Status: offline
    Re: Need some help with the correct startup sequence for the lcd display on picdem plus (2 2015/04/28 18:00:19 (permalink)
    0
    DarioG
    Why don't you use an ASCII char for real? grin instead of 0x40...
     
    Your init sounds look enough, since you *can* write something...


    i tried a counter for ascii simulation and all the chars are displayed, not sequential, but with gaps as mentioned on some webs.
    but i can't switch to the second line. 
     
    the current lcd config:

     
     
     
     
     
     
     
    send_command_byte(0x18); // 00011000 Initialise
    __delay_ms(5);
    send_command_byte(0x08); // 00001000 Initialise
    __delay_ms(5);
    send_command_byte(0x01); // 00000001 clean
    __delay_ms(5);
    send_command_byte(0x06); // 00000110
     
     
     
     
     
     
     

     
    the following code fils the first row on the ocular om1614, but nothing on the second.

     
     
     
    while(1){
     
     
     
    send_command_byte(0x01); // clear

    send_data_byte(lcd_counter);
    send_data_byte(lcd_counter);
    send_data_byte(lcd_counter);
    send_data_byte(lcd_counter);
    send_data_byte(lcd_counter);
    send_data_byte(lcd_counter);
    send_data_byte(lcd_counter);
    send_data_byte(lcd_counter);
    send_data_byte(lcd_counter);
    send_data_byte(lcd_counter);
    send_data_byte(lcd_counter);
    send_data_byte(lcd_counter);
    send_data_byte(lcd_counter);
    send_data_byte(lcd_counter); 
    send_data_byte(lcd_counter);
    send_data_byte(lcd_counter);
     
     
     
     
     
     
     

    send_command_byte(0xC0); // goto second row.

    send_data_byte(lcd_counter); 
    send_data_byte(lcd_counter); 
    send_data_byte(lcd_counter); 
    send_data_byte(lcd_counter); 
    send_data_byte(lcd_counter); 
    send_data_byte(lcd_counter); 
    send_data_byte(lcd_counter); 
    send_data_byte(lcd_counter); 
    send_data_byte(lcd_counter); 
    send_data_byte(lcd_counter); 
    send_data_byte(lcd_counter);
    send_data_byte(lcd_counter); 
    send_data_byte(lcd_counter); 
    send_data_byte(lcd_counter); 
    send_data_byte(lcd_counter); 
    send_data_byte(lcd_counter); 
     
     
     
     
     
     
     
    lcd_counter++;
     
     
     
    for(int number = 0; number != 100; number++) __delay_ms(10);
     
     
     
    };
     
     
     

     
    post edited by NaturalDemon - 2015/04/28 18:08:47
    #8
    NaturalDemon
    Super Member
    • Total Posts : 257
    • Reward points : 0
    • Status: offline
    Re: Need some help with the correct startup sequence for the lcd display on picdem plus (2 2015/04/28 18:02:47 (permalink)
    0
    i watch and tried tons of them, even the one microchip supplies with the board and none seam to work and have problems.
    so i try to figure it out myself, ofcourse i keep on eye on the funcions i see.
     
    #9
    ric
    Super Member
    • Total Posts : 23200
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Need some help with the correct startup sequence for the lcd display on picdem plus (2 2015/04/28 18:03:08 (permalink)
    +1 (1)
    Why are all the commands sending the setup data commented out?
    You're wasting everyone's time by NOT updating the comments. That's just being lazy.
    Why are you sending 0xFF and 0x40 as the characters to display (when the comment says 'H'). At least use real ASCII characters to you can see if it's working.

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #10
    NaturalDemon
    Super Member
    • Total Posts : 257
    • Reward points : 0
    • Status: offline
    Re: Need some help with the correct startup sequence for the lcd display on picdem plus (2 2015/04/28 18:06:27 (permalink)
    0
    ric
    Why are all the commands sending the setup data commented out?
    You're wasting everyone's time by NOT updating the comments. That's just being lazy.
    Why are you sending 0xFF and 0x40 as the characters to display (when the comment says 'H'). At least use real ASCII characters to you can see if it's working.


    sorry, i was to lazy to clean it up, but i did now.
    #11
    DarioG
    Allmächtig.
    • Total Posts : 54081
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: Oesterreich
    • Status: offline
    Re: Need some help with the correct startup sequence for the lcd display on picdem plus (2 2015/04/29 01:08:27 (permalink)
    +1 (1)
    In the end, I may think of some R-M-W effect...
    Which PIC are you using, and how are the RS etc pins defined? It could be that the delays in "init" make it work, but a send_command just after a send_data runs into troubles...

    GENOVA :D :D ! GODO
    #12
    vloki
    Jo, alla!
    • Total Posts : 6803
    • Reward points : 0
    • Joined: 2007/10/15 00:51:49
    • Location: Germany
    • Status: offline
    Re: Need some help with the correct startup sequence for the lcd display on picdem plus (2 2015/04/29 01:47:52 (permalink)
    +1 (1)
    If you still have problems, try my LCD test project ...
    (includes a configuration for pd2+, 4520)
     
    <edit> d*mn, attachment not workingmad
    post edited by vloki - 2015/04/29 02:39:42

    Uffbasse !
    #13
    i1ctg
    Super Member
    • Total Posts : 206
    • Reward points : 0
    • Joined: 2012/10/18 08:43:35
    • Location: OMEGNA-VB- ITALY
    • Status: offline
    Re: Need some help with the correct startup sequence for the lcd display on picdem plus (2 2015/04/29 02:36:19 (permalink)
    +1 (1)
    for 4 bit interface and 2 lines you have to start with command  0x28 and i do not see it.
    to show "H" you have to send data 0x48, according to your gif the displays seems to work.
    #14
    vloki
    Jo, alla!
    • Total Posts : 6803
    • Reward points : 0
    • Joined: 2007/10/15 00:51:49
    • Location: Germany
    • Status: offline
    Re: Need some help with the correct startup sequence for the lcd display on picdem plus (2 2015/04/29 02:53:02 (permalink)
    +1 (1)
    vlokiIf you still have problems, try my LCD test project ...
    (includes a configuration for pd2+, 4520)
     
    <edit> d*mn, attachment not workingmad
    Ok, posted there ->

    4/8bit LCD library for HD44780, HD47780, ST7036 TestProject

     
    <edit> attachments seems to work again ...
    post edited by vloki - 2015/06/15 00:10:16

    Uffbasse !
    #15
    NaturalDemon
    Super Member
    • Total Posts : 257
    • Reward points : 0
    • Status: offline
    Re: Need some help with the correct startup sequence for the lcd display on picdem plus (2 2015/04/30 18:47:51 (permalink)
    0
    after playing around a little, i found out how to reach the second line.
    but strangely, i see 3 small p´s and multiple capital P´s, multiple R & r.
    but no numbers and many of the alphabet seem to be missing.
    i'm wondering if this display is broken?
     
    this is what i tested
    // 0b01110000 = p
    // 0b01110001 = p
    // 0b01110010 = r
    // 0b01110011 = r(small)
    // 0b01110100 = p
     
    most or many of the "strange" sign/chars do coincide with the  hitachi hd 447788 datasheet.
     
     

     
    int n;
    typedef union {
     
    struct {
    unsigned bit0 : 1;
    unsigned bit1 : 1;
    unsigned bit2 : 1;
    unsigned bit3 : 1;
    unsigned bit4 : 1;
    unsigned bit5 : 1;
    unsigned bit6 : 1;
    unsigned bit7 : 1;
    };
    struct {
    unsigned lsb : 1;
    unsigned : 6; // # Unnamed padding.
    unsigned msb : 1;
    };
    struct {
    unsigned int Lo_Nibble : 4;
    unsigned int Hi_Nibble : 4;
    };
    unsigned char byte;
    //unsigned int todo : 1;
    //Type_of_Message type_of_message;
    } Nibble;
     
     
     
     
     
     
     
    Nibble nb;
    nb.Hi_Nibble = 0b1000;
    nb.Lo_Nibble = 0b0100;
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    unsigned char lcd_counter = 00;
     
     
     
     
     
     
     
    while(1)
     
     
     
     
     
     //send_command_byte(0xC0); // Go to start of line 2 does not work!!!
     
    for (n=0 ; n<80 ; ++n){
    if(n<40){
    Tx((nb.Hi_Nibble<<4)| nb.Lo_Nibble);
     send_data_byte((nb.Hi_Nibble<<4)| nb.Lo_Nibble); // line 1
    }
    else{
    send_data_byte(lcd_counter); // line 2
    }
     };
     
     
     
     
     
     
     
    lcd_counter++;
     
     
     
    for(int number = 0; number != 100; number++) __delay_ms(10);
     
     
     
    }
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    void send_nibble(unsigned char nibble)
    {
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    // For 4-bit interface data, only four bus lines (DB4 to DB7) are used for transfer. Bus lines DB0 to DB3
    // are disabled. The data transfer between the HD44780U and the MPU is completed after the 4-bit data
    // has been transferred twice. As for the order of data transfer, the four high order bits (for 8-bit operation,
    // DB4 to DB7) are transferred before the four low order bits (for 8-bit operation, DB0 to DB3).
    // The busy flag must be checked (one instruction) after the 4-bit data has been transferred twice. Two
    // more 4-bit operations then transfer the busy flag and address counter data.
     
     
     
     
     
     
     

    // Shift_data(nibble);
    //Tx(nibble);
     
     
     
    //Shift_data(nibble); // use 74hc595
    // Set RD0-3 without affecting RD4-7
    Nop(); // Small delay
    Nop();
    LATD = (LATD & 0xF0) + nibble;
    //delay_ms(1);
    __delay_us(500);
    // Note: data is latched on falling edge of pin E
    PIN_E = 0;
    //delay_ms(1);
    __delay_us(500);
    PIN_E = 1;
    LATD = (LATD & 0xF0) + 0b0000;
    //delay_ms(1); // Enough time even for slowest command
    __delay_us(500);

    //LATDbits.LATD0 = LATDbits.LATD1 = LATDbits.LATD2 = LATDbits.LATD3 = OFF;
    }
     
     
     
     
     
     
     
    // Send a command byte (i.e. with pin RS low)
    void send_command_byte(unsigned char byte)
    {
    Nibble temp;
    temp.byte = byte;
    Shift_data(temp.byte);
    PIN_RS = 0;
    __delay_us(500);
    send_nibble(temp.Hi_Nibble);
    send_nibble(temp.Lo_Nibble);
    //send_nibble(byte >> 4);
    //send_nibble(byte & 0xF);
    }
     
     
     
     
     
     
     
    // Send a data byte (i.e. with pin RS high)
    void send_data_byte(unsigned char byte)
    {
    Nibble temp;
    temp.byte = byte;
    Shift_data(temp.byte);
    PIN_RS = 1;
    __delay_us(500);
    send_nibble(temp.Hi_Nibble);
    send_nibble(temp.Lo_Nibble);
    //send_nibble(byte >> 4);
    //send_nibble(byte & 0xF);
    PIN_RS = 0;
    __delay_us(500);
    }
     
     
     

    post edited by NaturalDemon - 2015/04/30 18:55:59
    #16
    Jump to:
    © 2019 APG vNext Commercial Version 4.5