Hello,
I am currently having trouble getting my Optrex display to work properly. I am using the Explorer 16 development board from Microchip with the PIC24HJ64GA004. I wasn't getting anything after programming so I decided to look at it through the in-circuit debugger. I am using a parallel interface and reading back the busy flag that the lcd screen sends back via pin D7. I can get through most of the initialization but get stuck waiting for the busy flag pin to clear after sending the LCD Display On/Off command 0xAF.
This is the initialization code:
lcd_command(0xA3); // set LCD bias to 1/7 A2 = 1/9
lcd_command(0xA1); // inverse scan (L to R)
lcd_command(0xC0); // Scan commons top to bottom
lcd_command(0x40); // start COM scan at line address 00H
lcd_command(0x25); // sets internal resistor ratio (1+(Rb/Ra)) = 3.0
lcd_command(0x81); // access the electronic volume register
lcd_command(0x20); // set value of EVR to control contrast. From graph on page 22 of AN.
lcd_command(0x2C); // (Datasheet says to use 0x2F - will not clear busy flag)
lcd_command(0xA4); // Normal Display (Set to 0xA5 to turn all pixels on for test)
// lcd_command(0xE7);
----> lcd_command(0xAF); // Display ON (this is where it gets stuck)
lcd_command(0xB0); // Select RAM page 0 to start writing at pixel 0 vertically.
lcd_command(0x10); // Set upper 4 bits of column starting address to 00H
lcd_command(0x00); // Set lower 4 bits of column starting address to 00H
void lcd_command(unsigned short data)
{
nRD = 1; // pull read bit high PORTBbits.RB14
A0 = 0; // clear A0 bit (command)
LCD_DATA_IO = data; // set portb to data or read high write
nWR = 0; // clear write bit
wait(30000);
nWR = 1; // pull write bit high
LCD_BF_DIR = 1; // sets direction of busy flag bit to input (D7)
nRD = 0; // clears read bit to allow for read
while(LCD_BUSY_FLAG); // waits for busy flag to clear
nRD = 1; // sets read bit
LCD_BF_DIR = 0; // sets direction of busy flag bit to output
}
Could anyone please give me any clues as to why I am stuck at the Display On/Off part of the initialization sequence. The lcd_command and reading the busy flag seem to work as I get that far. Am I sending the wrong data or have I missed a command before that?
Thank you in advance
I am currently having trouble getting my Optrex display to work properly. I am using the Explorer 16 development board from Microchip with the PIC24HJ64GA004. I wasn't getting anything after programming so I decided to look at it through the in-circuit debugger. I am using a parallel interface and reading back the busy flag that the lcd screen sends back via pin D7. I can get through most of the initialization but get stuck waiting for the busy flag pin to clear after sending the LCD Display On/Off command 0xAF.
This is the initialization code:
lcd_command(0xA3); // set LCD bias to 1/7 A2 = 1/9
lcd_command(0xA1); // inverse scan (L to R)
lcd_command(0xC0); // Scan commons top to bottom
lcd_command(0x40); // start COM scan at line address 00H
lcd_command(0x25); // sets internal resistor ratio (1+(Rb/Ra)) = 3.0
lcd_command(0x81); // access the electronic volume register
lcd_command(0x20); // set value of EVR to control contrast. From graph on page 22 of AN.
lcd_command(0x2C); // (Datasheet says to use 0x2F - will not clear busy flag)
lcd_command(0xA4); // Normal Display (Set to 0xA5 to turn all pixels on for test)
// lcd_command(0xE7);
----> lcd_command(0xAF); // Display ON (this is where it gets stuck)
lcd_command(0xB0); // Select RAM page 0 to start writing at pixel 0 vertically.
lcd_command(0x10); // Set upper 4 bits of column starting address to 00H
lcd_command(0x00); // Set lower 4 bits of column starting address to 00H
void lcd_command(unsigned short data)
{
nRD = 1; // pull read bit high PORTBbits.RB14
A0 = 0; // clear A0 bit (command)
LCD_DATA_IO = data; // set portb to data or read high write
nWR = 0; // clear write bit
wait(30000);
nWR = 1; // pull write bit high
LCD_BF_DIR = 1; // sets direction of busy flag bit to input (D7)
nRD = 0; // clears read bit to allow for read
while(LCD_BUSY_FLAG); // waits for busy flag to clear
nRD = 1; // sets read bit
LCD_BF_DIR = 0; // sets direction of busy flag bit to output
}
Could anyone please give me any clues as to why I am stuck at the Display On/Off part of the initialization sequence. The lcd_command and reading the busy flag seem to work as I get that far. Am I sending the wrong data or have I missed a command before that?
Thank you in advance
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.