CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Driver for 84x48 TCM8448A GLCD (ST7541 cntllr)

 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
PICoHolic



Joined: 04 Jan 2005
Posts: 224

View user's profile Send private message

Driver for 84x48 TCM8448A GLCD (ST7541 cntllr)
PostPosted: Thu Feb 05, 2009 6:40 am     Reply with quote

Code:

#ifndef  TCM8448A_H
#define  TCM8448A_H
///////////////////////////////////////////////////////////////////////////////
// signals
#bit  A0 =  PORTB.0
#bit  CS =  PORTB.1
#bit  RSET= PORTB.2
///////////////////////////////////////////////////////////////////////////////
// commands
#define  NOP      0x00
#define  FUNCSET  0x20
#define  DISPCNT  0x08
#define  YADDRSS  0x40
#define  XADDRSS  0x80
#define  BIASSYS  0x10
#define  V0VOLTG  0x80
//-----------------------
#define  PD       0x04
#define  V        0x02
#define  H        0x01
//-----------------------
#define  DISPBLNK 0x00
#define  DISPNORM 0x04
#define  DISPAON  0x01
#define  DISPINV  0x05
///////////////////////////////////////////////////////////////////////////////
// GLCD RAM image
BYTE GLCDRAM[6][84];
///////////////////////////////////////////////////////////////////////////////
#define  GLCD_WIDTH  84
///////////////////////////////////////////////////////////////////////////////
// Function to write commands
void glcd_WriteCommand(unsigned int8 C)
{
   A0 = 0;  //command
   delay_cycles(1);
   CS = 0;
   delay_cycles(1);
   spi_write(C);
   delay_cycles(1);
   CS = 1;
}
///////////////////////////////////////////////////////////////////////////////
// Function to write data
void glcd_WriteData(unsigned int8 D)
{
   A0 = 1;  //data
   delay_cycles(1);
   CS = 0;
   delay_cycles(1);
   spi_write(D);
   delay_cycles(1);
   CS = 1;
}
///////////////////////////////////////////////////////////////////////////////
// GLCD initialization; should be called before any other opreation
void glcd_init()
{
   unsigned int8 i,j;
   
   setup_spi(SPI_MASTER|SPI_XMIT_L_TO_H|SPI_L_TO_H|SPI_CLK_DIV_4);
   RSET = 1;
   delay_ms(1);
   glcd_WriteCommand(FUNCSET | V |H);
   glcd_WriteCommand(BIASSYS | 0x04);
   glcd_WriteCommand(V0VOLTG | 0x70);
   glcd_WriteCommand(FUNCSET);
   glcd_WriteCommand(DISPCNT | DISPNORM);
   glcd_WriteCommand(XADDRSS | 0x00);
   glcd_WriteCommand(YADDRSS | 0x00);
   delay_cycles(1);
   
   //clear display:
   for (i=0;i<6;i++)
      for(j=0;j<84;j++)
      {
         glcd_WriteData(0x00);
         GLCDRAM[i][j] = 0x00;
      }
   
}
///////////////////////////////////////////////////////////////////////////////
// function to draw a pixel at a specific location and color
void glcd_pixel(unsigned int8 x, unsigned int8 y, int1 color)
{
   unsigned int8 yo;
   
   yo = y/8;
   
   if (color)
   {
      bit_set(GLCDRAM[yo][x], y%8);
   }
   else
   {
      bit_clear(GLCDRAM[yo][x], y%8);
   }
   
   glcd_WriteCommand(XADDRSS | x);
   glcd_WriteCommand(YADDRSS | yo);
   glcd_WriteData(GLCDRAM[yo][x]);
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
#endif
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group