  | 
	  | 
		 
	 
	
		| View previous topic :: View next topic   | 
	 
	
	
		| Author | 
		Message | 
	 
	
		
			newbie4life
 
 
  Joined: 18 Dec 2006 Posts: 2
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				| cfag12232d graphic lcd | 
			 
			
				 Posted: Thu Jan 11, 2007 5:44 pm     | 
				     | 
			 
			
				
  | 
			 
			
				Version of your compiler: 4.020
 
Target PIC Microcontroller (PIC16F877, 18F452, etc): PicDem2 Plus 18F4520
 
Standard Run Mode or Debug Mode: standard
 
Target voltage (5V, 3.3V, etc): 9V
 
Target oscillator speed, type (20Mhz, RC, Strip Cut, etc): 24MHz
 
 
I toggled all the pins to see if the wiring was correct, and it is.  Also ohmed it out.  I only get garbage on the lcd.  Here is the source code.  Free for download from www.picmodules.com  I've made modifications to it, but it doesn't seem to work.  
 
 
If anyone could help, I would appreciate it.  Hopefully someone can see the error, and/or has used this similar device.  Any advice/comments is welcomed!  Thanks.
 
 
 
Main.C
 
 
 	  | Code: | 	 		  
 
//****************************************************************
 
// TITLE:   MAIN.C
 
// DATE:    04 DEC 05
 
// BY:      JV
 
// DESCRIPTION: Main project file for SED1520 ddemo applicatiton
 
//----------------------------------------------------------------
 
// Revision:    V1.0 (first release)
 
//****************************************************************
 
 
// Select a Processor
 
// Note:    Default is setup for 16F877A processor
 
//#define _16F877A                          // Un-comment the micro
 
#define _18F4520                            // that you are using
 
//#define _18F4620                          // make sure all others
 
                                            // are commented out
 
#ifdef _16F877A
 
   #include <16f877a.h>
 
   #fuses HS,NOWDT,NOPROTECT,NOLVP
 
#endif
 
 
#ifdef _18F4520
 
   #include <18f4520.h>
 
  #fuses HS,NOWDT,NOLVP,NOBROWNOUT,NOLPT1OSC,NOXINST,NOFCMEN,NOIESO,NOPBADEN 
 
#endif
 
 
#ifdef _18F4620
 
   #include <18f4620.h>
 
  #fuses HS,NOWDT,NOLVP,NOBROWNOUT,NOLPT1OSC,NOXINST,NOFCMEN,NOIESO,NOPBADEN 
 
#endif
 
 
//#device ICD=TRUE
 
#use delay(clock=24,000,000)
 
 
#define FAST_GLCD                       // Graphics.c driver 
 
#include "graphics.c"                   // Graphics.c driver
 
#include <math.h>                       // Graphics.c driver
 
 
// Some test text for displaying on the LCD display
 
char  TestText[]  = "PICCore",
 
      TestText2[] = "SED1520 LCD on a ...";
 
 
//=================================================================
 
// The main application
 
//=================================================================
 
void main() 
 
  {
 
  int8 i,j,k;
 
  InitSED1520();                        // Initialise the SED1520 controllers
 
  
 
 
// Clear the display RAM first--------------//
 
for (k=0;k<2;k++)                           // Clear both controlers data
 
    {
 
     SIDE=k;
 
     for (j=0;j<4;j++)                       // Now go through all pages 
 
       {                                   // and clear the LCD RAM
 
          LCDCWrite(184+j);                  // so that the display is cleared    
 
        LCDCWrite(0); 
 
         for (i=0;i<62;i++) LCDWrite(0x00);
 
        }
 
   }
 
//------------------------------------------//
 
 
   // Turn on BL
 
   output_low(PIN_C2);
 
   /*
 
   glcd_rect(5,30,10,10,NO,ON);             // Draw some rectangles 
 
   glcd_rect(5,30,10,22,YES,ON);
 
   glcd_rect(12,30,17,10,NO,ON);        
 
   glcd_rect(12,30,17,14,YES,ON);
 
   glcd_rect(19,30,24,10,NO,ON);
 
   glcd_rect(19,30,24,23,YES,ON);
 
   glcd_rect(26,30,31,10,NO,ON);
 
   glcd_rect(26,30,31,16,YES,ON);
 
   */   
 
   glcd_text57(2, 2, TestText2, 1, ON);     // Display some text on the LCD
 
   glcd_text57(40, 12, TestText, 2, ON);    // Display some text on the LCD
 
 
   //glcd_line(35,27,122,27,ON);              // then some lines
 
   //glcd_line(35,29,122,29,ON);
 
 
while(1);                                   // ...and stop
 
 
}//End Main
 
 
 | 	  
 
 
sed1520lcd.c
 
 
 	  | Code: | 	 		  
 
//****************************************************************
 
// TITLE:   SED1520LCD.C
 
// DATE:    04 DEC 05
 
// BY:      JV
 
// DESCRIPTION: SED1520 code for CCS graphics
 
//              driver
 
//----------------------------------------------------------------
 
// Revision:    V1.0 (first release)
 
//****************************************************************
 
 
// PICCore Pin definitions----------//
 
#define LCD_RES     PIN_A0          // LCD reset pin
 
#define LCD_CS1     PIN_E1          // Enable Left Side of LCD
 
#define LCD_CS2     PIN_E2          // Enable Right Side of LCD
 
#define LCD_RW      PIN_C1          // Read/Write
 
#define LCD_A0      PIN_C0          // Control or Data
 
#define LCD_BL      PIN_C2          // LCD B/L
 
#define B0          PIN_B0          // Databus 0
 
#define B1          PIN_B1          // Databus 1
 
#define B2          PIN_B2          // Databus 2
 
#define B3          PIN_B3          // Databus 3
 
#define B4          PIN_B4          // Databus 4
 
#define B5          PIN_B5          // Databus 5
 
#define B6          PIN_B6          // Databus 6
 
#define B7          PIN_B7          // Databus 7
 
 
// Tell CCS Graphics.c how big the display is
 
#define GLCD_WIDTH   122            // Number of Horizontal pixels
 
#define GLCD_HEIGHT   32            // Number of Vertical Pixels
 
 
#define LEFT    1
 
#define RIGHT   0
 
 
// Global Variables for this application (LCD)
 
int   SIDE;                         // Left or Right side of LCD
 
 
// Function Prototype for CCS Graphics.c driver 
 
void glcd_pixel(int8, int8, int1);  // Required for CCS GRAPHICS.C
 
 
 
//===============================================================
 
// command_write (Cdata)
 
// Write command data to the LCD
 
// See SED1520 datasheet for more info
 
//===============================================================
 
void LCDCWrite(int8 CData)           // Write Instruction to LCD
 
  {
 
   if (SIDE==LEFT)
 
    {
 
     OUTPUT_LOW(LCD_A0);            // Instruction (not display data)
 
     OUTPUT_LOW(LCD_RW);            // We are going to WRITE Data
 
     OUTPUT_LOW(LCD_CS1);           // CS Low on the LEFT side of the display
 
     delay_cycles(10);
 
 
     OUTPUT_HIGH(LCD_CS1);          // CS High (starts cycle)
 
     OUTPUT_B(CData);               // Put the data on the bus
 
     delay_cycles(2);               
 
 
     OUTPUT_LOW(LCD_CS1);           // Latch the data into the LCD
 
     delay_cycles(2);               
 
    }
 
else // The RIGHT hand side
 
    {
 
     OUTPUT_LOW(LCD_A0);            // Instruction (not display data)
 
     OUTPUT_LOW(LCD_RW);            // We are going to WRITE Data
 
     OUTPUT_LOW(LCD_CS2);           // CS Low on the RIGHT side of the display
 
     delay_cycles(10);
 
 
     OUTPUT_HIGH(LCD_CS2);          // CS High (starts cycle)
 
    OUTPUT_B(CData);                // Put the data on the bus
 
     delay_cycles(2);
 
 
     OUTPUT_LOW(LCD_CS2);           // Latch the data into the LCD 
 
     delay_cycles(2);  
 
    }
 
 }
 
 
 
//===============================================================
 
// Data write (DData)
 
// Writes display data to the LCD
 
//===============================================================
 
void LCDWrite(int8 DData)               // Write Data to LCD
 
  {
 
   OUTPUT_HIGH(LCD_A0);                 // Data (not instruction)
 
   OUTPUT_LOW(LCD_RW);                // We are going to WRITE Data
 
   if(SIDE==LEFT)OUTPUT_LOW(LCD_CS1);   // If Left side then use CS1
 
   if(SIDE==RIGHT)OUTPUT_LOW(LCD_CS2);  // If Right side then use CS2 
 
   delay_cycles(2);
 
 
   if(SIDE==LEFT) OUTPUT_HIGH(LCD_CS1); 
 
   if(SIDE==RIGHT) OUTPUT_HIGH(LCD_CS2);
 
   OUTPUT_B(DData);                   // Put the data onto the bus
 
   delay_cycles(10); 
 
 
   if(SIDE==LEFT) OUTPUT_LOW(LCD_CS1);  // and latch the data into 
 
   if(SIDE==RIGHT) OUTPUT_LOW(LCD_CS2); // the LCD display
 
   delay_cycles(2);
 
  }
 
 
 
//===============================================================
 
// Display data read
 
// Reads the display data pointed to by the page, column and
 
// chip select. Returns the data.
 
//===============================================================
 
int8 LCDRead()                          // Read Data from LCD
 
  {
 
   int8 DData;
 
 
   if(SIDE==LEFT) OUTPUT_HIGH(LCD_CS1);  
 
   if(SIDE==RIGHT) OUTPUT_HIGH(LCD_CS2);   
 
 
   OUTPUT_HIGH(LCD_A0);                 // Data
 
   OUTPUT_HIGH(LCD_RW);                // Read Data
 
   if(SIDE==LEFT)OUTPUT_LOW(LCD_CS1);
 
   if(SIDE==RIGHT)OUTPUT_LOW(LCD_CS2);
 
   delay_cycles(2);
 
 
   set_tris_b(0xff);   // Allow LCD to drive the data lines
 
 
   if(SIDE==LEFT) OUTPUT_HIGH(LCD_CS1);
 
   if(SIDE==RIGHT) OUTPUT_HIGH(LCD_CS2);
 
 
   delay_cycles(50);
 
   DData=INPUT_B();                   // Get the data
 
   if(SIDE==LEFT) OUTPUT_LOW(LCD_CS1);
 
   if(SIDE==RIGHT) OUTPUT_LOW(LCD_CS2);
 
   delay_cycles(2);
 
 
return(DData);
 
 }
 
 
//===============================================================
 
// Draw a single pixel 
 
// This is required by the Graphics.c driver file provided by 
 
// CCS. It tells the driver how to draw a single pixel anywhere
 
// on the LCD display
 
// x=1 to 122      y=1 to 32     color=1=ON    color=0=OFF
 
//===============================================================
 
void glcd_pixel(int8 x, int8 y, int1 color)   
 
{
 
int8 ucMask;
 
int8 i;
 
int8 Data;
 
 
// Which side of the display (which SED1520 controller)
 
if (x<61>8)y-=((Data-184)*8);              // y should always be 1-8
 
 
// Horizontal position (column)
 
if (x>=62)                                // x should always be 0-61
 
   x-=61;                               // for each half of the LCD
 
x-=1;                                   // 
 
 
LCDCWrite(x);                           // Go to column 'x' 
 
 
LCDCWrite(0xe0);                       // Start R-M-Write operation
 
  LCDRead();                          // Dummy Read
 
  Data = LCDRead();                      // Read LCD dissplay data
 
 
  ucMask = 1;                           // Create a bit mask of the
 
  for (i=1;i<y;i++)                      // pixel to change
 
       ucMask<<=1;                      // 
 
 
  if (color) Data|=ucMask;              // Set or clear the pixel as                        
 
  else Data&=~ucMask;                   // requested
 
  LCDWrite(Data);
 
LCDCWrite(0xee);                      // End R-M-Write operation
 
}
 
 
//===================================================================
 
// Initialise the SED11520 controllers
 
// for the display type we are using
 
//===================================================================
 
void InitSED1520()
 
{
 
 int8 i;
 
 set_tris_b(0x00);
 
 set_tris_e(0xF8);
 
 set_tris_c(0xF8);
 
 
 // Setup both SED1520 ccontrollers
 
 for (i=0;i<2;i++)
 
    {
 
    SIDE=i;
 
   LCDCWrite(0xaf);        // Turn on the display
 
   LCDCWrite(0xa4);        // Static drive is off
 
   LCDCWrite(0xa9);        // Duty cycle is set to 1/32
 
   LCDCWrite(0xe2);        // Reset the chip
 
   LCDCWrite(0xa0);        // Set ADC
 
   LCDCWrite(0xee);        // Read modify write disabled
 
   LCDCWrite(0xc0);        // Set the start position to 
 
   LCDCWrite(0xb8);        // the top left of the display
 
   LCDCWrite(0x00);        // in column 0
 
   }
 
    OUTPUT_LOW(LCD_CS1);    // De-select each side to start
 
    OUTPUT_LOW(LCD_CS2);    // 
 
    delay_ms(60);
 
}
 
 | 	 
  | 
			 
		  | 
	 
	
		  | 
	 
	
		
			treitmey
 
 
  Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI   USA 
			
			 
			 
			
			 
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Thu Jan 11, 2007 5:56 pm     | 
				     | 
			 
			
				
  | 
			 
			
				Just a shot in the dark,.. but the delay_cycles in the driver can be a sort of a got ya.  That is because your clock may not be the same as my clock.  replace the delay_cycles with a delay_ms(200)
 
thats a big number, and can be changed to something resonable if it fixes anything. | 
			 
		  | 
	 
	
		  | 
	 
	
		
			newbie4life
 
 
  Joined: 18 Dec 2006 Posts: 2
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Thu Jan 11, 2007 6:29 pm     | 
				     | 
			 
			
				
  | 
			 
			
				| Hi, thanks for the input, but yeah, that was one of the first things I've tried. | 
			 
		  | 
	 
	
		  | 
	 
	
		 | 
	 
 
  
	 
	    
	   | 
	
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
  
		 |