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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/08/03 11:16
Read: times


 
#35908 - RE: SED1530 LCD controller
You may try this. It was written for a Densitron module (33 x 100 dots) and works OK. I have adapted it a little so that it's more easy to read.

void StartupLCD()
{
LCD_Reset();// Reset module
LCD_On();// Switch LCD on
if (Option[0]==1) // Black on white or inverse? Default=B on W
LCD_SetInverseDisplay(); LCD_SetPowerMode();
LCD_SetADCNormal();
LCD_SetContrast(8); // Contrast to medium
LCD_SetStartDisplayLine(0); // Set pointer to start of display RAM
LCD_SetPageAddress(0); // Switch to LCD RAM Page 0 (first page)
LCD_ClearDisplay(); // Clear contents of display RAM
}

// LCD_SetStartDisplayLine()
// -------------------------
// Set the display line for TOS (top of screen).
// ---------------------------------------------
void LCD_SetStartDisplayLine(unsigned char StartDisplayLine)
{
if (StartDisplayLine>63)
StartDisplayLine=0;
LCD_WriteCommand(64+StartDisplayLine);
}

// LCD_SetPageAddress()
// --------------------
// Set the page address to which data is written.
// ----------------------------------------------
void LCD_SetPageAddress( unsigned char PageAddress)
{
if (PageAddress>8)
PageAddress=0;
LCD_WriteCommand(0xb0+PageAddress);
}


// LCD_On()
// --------
// Swith LCD module on.
// --------------------
void LCD_On()
{
LCD_WriteCommand(0xaF);
}

// LCD_Off()
// ---------
// Swith LCD module off.
// ---------------------
void LCD_Off()
{
LCD_WriteCommand(0xaE);
}

// LCD_SetContrast()
// -----------------
// Sets LCD contrast.
// ------------------
void LCD_SetContrast (unsigned char Contrast)
{
if (Contrast >31)
Contrast=31;
LCD_WriteCommand(128+Contrast);
}


// LCD_SetPowerMode()
// ------------------
// Set the LCD driver power mode. Refer to datasheet.
// --------------------------------------------------
void LCD_SetPowerMode()
{
LCD_WriteCommand(0x2f);
}

// LCD_SetADCNormal()
// ------------------
// Refer to datasheet.
// -------------------
void LCD_SetADCNormal()
{
LCD_WriteCommand(0xa0);
}

// LCD_SetADCReverse()
// -------------------
// Refer to datasheet.
// -------------------
void LCD_SetADCReverse()
{
LCD_WriteCommand(0xa1);
}

// LCD_SetNormalDisplay()
// ----------------------
// Set display-mode to 'black on white'.
// ------------------------------------
void LCD_SetNormalDisplay()
{
LCD_WriteCommand(0xa6);
}

// LCD_SetInverseDisplay()
// ----------------------
// Set display-mode to 'white on black'.
// ------------------------------------
void LCD_SetInverseDisplay()
{
LCD_WriteCommand(0xa7);
}


// LCD_ClearDisplay()
// ------------------
// Write all zero's to the LCD module RAM, effectively clearing the display.
// -------------------------------------------------------------------------
void LCD_ClearDisplay()
{
unsigned char Page;
unsigned char Column;

for (Page=0;Page<8;Page++) // Loop for 8 memory 'pages'
{
LCD_SetColumnAddress(0); // Reset to column 0
LCD_SetPageAddress(Page); // Goto page
for (Column=0;Column<100;Column++)// Repeat for 100 columns
LCD_WriteData(0); // Write '0'
}
}

// LCD_ResetBias()
// --------------
// Reset LCD module bias voltage. Refer to datasheet.
// --------------------------------------------------
void LCD_ResetBias()
{
LCD_WriteCommand(0xa2);
}

// LCD_Reset()
// -----------
// Force a software reset of the controller. Refer to datasheet.
// -------------------------------------------------------------
void LCD_Reset()
{
LCD_WriteCommand(0xe2);
}

// LCD_WriteCommand()
// ------------------
// Write a command for the LCD controller to the module.
// -----------------------------------------------------
void LCD_WriteCommand(unsigned char Command)
{
LCD_Sequence(0,Command);
}

// LCD_WriteData()
// ---------------
// Write a byte of data to the LCD module. RAM pointer is automatically
// incremented by LCD controller after the write operation.
// --------------------------------------------------------------------
void LCD_WriteData(unsigned char LCDData)
{
LCD_Sequence(1,LCDData);
}


// LCD_SetColumnAddress()
// ----------------------
// Write a new column-address to the LCD controller. This action is done in
// two separate write-commands: for high and low address. Refer to LCD module
// datasheet.
// -------------------------------------------------------------------------
void LCD_SetColumnAddress(unsigned char ColumnAddress)
{
unsigned char CALow, CAHigh;

if (ColumnAddress>0x83)
ColumnAddress=0;
CALow=ColumnAddress; // Split column address in 2 4-bit nibbles
CALow&=0x0F;
CAHigh=(ColumnAddress>>4);

LCD_WriteCommand(0x10+CAHigh); // Set high nibble
LCD_WriteCommand(CALow); // Set low nibble
}



// LCD_Sequence()
// --------------
// General routine to send data and/or commands to the LCD controller.
// The A0 line determines if the data to be output is a command or
// actually data. Refer to LCD controller datasheet for more info.
// ------------------------------------------------------------------
void LCD_Sequence(unsigned char A0Status,unsigned char WriteData)
{
if (A0Status==1) // Set A0 for data
LCD_A0=1;
else
LCD_A0=0; // or reset for command
LCD_RW=0; // Make sure RW line is low
LCD_DATA=WriteData; // Put data/command on data-bus
LCD_SELECT=1; // Set SEL line
LCD_ENABLE=0; // Clear ENABLE line
LCD_ENABLE=1; // Set ENABLE line
ShortPause(); // Insert a short pause to allow all lines to become
LCD_ENABLE=0; // stable; without this pause, the LCD may 'scramble'
ShortPause();
LCD_SELECT=0; // Release the SELECT line; data is clocked in now ...
LCD_A0=0;
}


List of 12 messages in thread
TopicAuthorDate
SED1530 LCD controller            01/01/70 00:00      
RE: SED1530 LCD controller            01/01/70 00:00      
RE: SED1530 LCD controller            01/01/70 00:00      
RE: SED1530 LCD controller            01/01/70 00:00      
RE: SED1530 LCD controller            01/01/70 00:00      
RE: SED1530 LCD controller            01/01/70 00:00      
Thanks Everyone            01/01/70 00:00      
RE: SED1530 LCD controller / Fonts            01/01/70 00:00      
   RE: SED1530 LCD controller / Fonts            01/01/70 00:00      
      RE: SED1530 LCD controller / Fonts            01/01/70 00:00      
RE: SED1520 LCD controller            01/01/70 00:00      
RE: SED1530 LCD controller            01/01/70 00:00      

Back to Subject List