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 support@ccsinfo.com

GLCD problem
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
hemnath



Joined: 03 Oct 2012
Posts: 241
Location: chennai

View user's profile Send private message

GLCD problem
PostPosted: Wed Apr 22, 2015 10:59 pm     Reply with quote

Hi all,
I am interfacing graphic LCD EA DOGM128X-6 which uses ST 7565R controller with pic 18F2520. Crystal freq: 4Mhz internal.

Double checked the hardware. Connections are correct. Power used for microcontroller and glcd display is +3.3V DC.

Below is the sample code to on the pixels on glcd:
Code:
#include "18F2520.h"
#fuses INTRC_IO
#use delay(clock=4000000)

// definitions
#define GLCD_CS1      PIN_A1
#define GLCD_RESET      PIN_A2
#define GLCD_A0         PIN_A0

#define GLCD_SCL       PIN_C3
#define GLCD_SDA       PIN_C4

void glcd_command(unsigned char command);
void glcd_data(unsigned char data);

void main()
{
   int i;
   output_low(GLCD_CS1);      

   output_low(GLCD_RESET);
   delay_ms(200);
   output_high(GLCD_RESET);

   delay_ms(10);

   glcd_command(0x40);         // initialization
   glcd_command(0xA1);
   glcd_command(0xC0);
   glcd_command(0xA6);
   glcd_command(0xA2);
   glcd_command(0x2F);
   glcd_command(0xF8);
   glcd_command(0x00);
   glcd_command(0x27);
   glcd_command(0x81);
   glcd_command(0x16);
   glcd_command(0xAC);
   glcd_command(0x00);
   glcd_command(0xAF);

   while(1)
   {
      i = 0;
      for(i = 0; i < 63; i++)
      {
         glcd_command(0x00+i);
         glcd_data(0xff);
         delay_ms(100);
      }
   }
}

void glcd_command(unsigned int8 command)
{
   int n;
   output_low(GLCD_A0);

   output_low(GLCD_CS1);
   
   for (n = 0; n < 8; n++)
   {
      if (command & 0x80)
      {
         output_high(GLCD_SDA);
      }
      else
      {
         output_low(GLCD_SDA);
      }
      
      // Pulse SCL
      output_high(GLCD_SCL);
      delay_ms(10);
      output_low(GLCD_SCL);
      
      command <<= 1;
   }   

   output_high(GLCD_CS1);
}

void glcd_data(unsigned int8 data)
{
   int n;
   
   output_high(GLCD_A0);

   output_low(GLCD_CS1);
   
   for (n = 0; n < 8; n++)
   {
      if (data & 0x80)
      {
         output_high(GLCD_SDA);
      }
      else
      {
         output_low(GLCD_SDA);
      }
      
      // Pulse SCL
      output_high(GLCD_SCL);
      delay_ms(10);
      output_low(GLCD_SCL);
      
      data <<= 1;
   }
   
   // Unselect the chip
   output_high(GLCD_CS1);
}


But there is nothing on display. Please help.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Apr 23, 2015 3:14 pm     Reply with quote

Quote:

pic 18F2520. Crystal freq: 4Mhz internal.

Double checked the hardware. Connections are correct. Power used for
microcontroller and glcd display is +3.3V DC.

The 18F2520 data sheet says, in Figures 26-1, 26-2 and 26-3 in the
Electrical Characteristics section, that the PIC will only work down to 4.2v,
unless it's the "LF" version. The regular versions of the PIC won't work
at 3.3v, or at least not reliably. Do you have the 18LF2520 ?
Data sheet:
http://ww1.microchip.com/downloads/en/DeviceDoc/39631E.pdf
hemnath



Joined: 03 Oct 2012
Posts: 241
Location: chennai

View user's profile Send private message

PostPosted: Thu Apr 23, 2015 9:19 pm     Reply with quote

Yes I'm using PIC 18LF2520.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Apr 24, 2015 12:22 am     Reply with quote

1. I notice you don't initialize your SCL or SDA lines. They should be set
to their inactive idle levels at the start of main(). Based on the EA DOGM
data sheet, SCL should be set to 1, initially. SDA doesn't matter, so just
set it to 0.

I also note that you, and they are using the wrong names for the SPI
signals. It should be SCK and SDO.

2. I also notice that you're not doing the clock (SCL) the way that they
show in the EA DOGM data sheet:
http://www.lcd-module.com/eng/pdf/grafik/dogm128e.pdf
On page 5, they show that SCL idles at a high level. A data bit is output,
and then SCL is pulsed low.

3. Also, you're pulsing SCL for 10ms. The ST7565R data sheet shows
the SCL high or low time only needs to be 25 ns minimum. You could
pulse SCL low for 1 usec and it would be OK. See Table 30 in the
ST7565R data sheet on page 64:
http://www.lcd-module.com/eng/pdf/zubehoer/st7565r.pdf
hemnath



Joined: 03 Oct 2012
Posts: 241
Location: chennai

View user's profile Send private message

PostPosted: Fri Apr 24, 2015 2:34 am     Reply with quote

Thanks PCM.

I made a search on google and i have found the below library for ST7565R driver.

st7565.c
Code:
/** Global buffer to hold the current screen contents. */
// This has to be kept here because the width & height are set in
// st7565-config.h
unsigned char glcd_buffer[SCREEN_WIDTH * SCREEN_HEIGHT / 8];

#ifdef ST7565_DIRTY_PAGES
unsigned char glcd_dirty_pages;
#endif

void glcd_pixel(unsigned char x, unsigned char y, unsigned char colour) {

    if (x > SCREEN_WIDTH || y > SCREEN_HEIGHT) return;

    // Real screen coordinates are 0-63, not 1-64.
    x -= 1;
    y -= 1;

    unsigned short array_pos = x + ((y / 8) * 128);

#ifdef ST7565_DIRTY_PAGES
#warning ** ST7565_DIRTY_PAGES enabled, only changed pages will be written to the GLCD **
    glcd_dirty_pages |= 1 << (array_pos / 128);
#endif

    if (colour) {
        glcd_buffer[array_pos] |= 1 << (y % 8);
    } else {
        glcd_buffer[array_pos] &= 0xFF ^ 1 << (y % 8);
    }
}

void glcd_blank() {
   int n,y,x;
    // Reset the internal buffer
    for (n = 1; n <= (SCREEN_WIDTH * SCREEN_HEIGHT / 8) - 1; n++) {
        glcd_buffer[n] = 0;
    }

    // Clear the actual screen
    for (y = 0; y < 8; y++) {
        glcd_command(GLCD_CMD_SET_PAGE | y);

        // Reset column to 0 (the left side)
        glcd_command(GLCD_CMD_COLUMN_LOWER);
        glcd_command(GLCD_CMD_COLUMN_UPPER);

        // We iterate to 132 as the internal buffer is 65*132, not
        // 64*124.
        for (x = 0; x < 132; x++) {
            glcd_data(0x00);
        }
    }
}

void glcd_refresh() {
   int y, x;
    for (y = 0; y < 8; y++) {

#ifdef ST7565_DIRTY_PAGES
        // Only copy this page if it is marked as "dirty"
        if (!(glcd_dirty_pages & (1 << y))) continue;
#endif

        glcd_command(GLCD_CMD_SET_PAGE | y);

        // Reset column to the left side.  The internal memory of the
        // screen is 132*64, we need to account for this if the display
        // is flipped.
        //
        // Some screens seem to map the internal memory to the screen
        // pixels differently, the ST7565_REVERSE define allows this to
        // be controlled if necessary.
#ifdef ST7565_REVERSE
        if (!glcd_flipped) {
#else
        if (glcd_flipped) {
#endif
            glcd_command(GLCD_CMD_COLUMN_LOWER | 4);
        } else {
            glcd_command(GLCD_CMD_COLUMN_LOWER);
        }
        glcd_command(GLCD_CMD_COLUMN_UPPER);

        for (x = 0; x < 128; x++) {
            glcd_data(glcd_buffer[y * 128 + x]);
        }
    }

#ifdef ST7565_DIRTY_PAGES
    // All pages have now been updated, reset the indicator.
    glcd_dirty_pages = 0;
#endif
}

void glcd_init() {

    // Select the chip
    output_low(GLCD_CS1);

    output_low(GLCD_RESET);

    // Datasheet says "wait for power to stabilise" but gives
    // no specific time!
    delay_ms(50);

    output_high(GLCD_RESET);

    // Datasheet says max 1ms here
    //DelayMs(1);

    // Set LCD bias to 1/9th
    glcd_command(GLCD_CMD_BIAS_9);

    // Horizontal output direction (ADC segment driver selection)
    glcd_command(GLCD_CMD_HORIZONTAL_NORMAL);

    // Vertical output direction (common output mode selection)
    glcd_command(GLCD_CMD_VERTICAL_REVERSE);

    // The screen is the "normal" way up
    glcd_flipped = 0;

    // Set internal resistor.  A suitable middle value is used as
    // the default.
    glcd_command(GLCD_CMD_RESISTOR | 0x3);

    // Power control setting (datasheet step 7)
    // Note: Skipping straight to 0x7 works with my hardware.
    //   glcd_command(GLCD_CMD_POWER_CONTROL | 0x4);
    //   DelayMs(50);
    //   glcd_command(GLCD_CMD_POWER_CONTROL | 0x6);
    //   DelayMs(50);
    glcd_command(GLCD_CMD_POWER_CONTROL | 0x7);
    //   DelayMs(10);

    // Volume set (brightness control).  A middle value is used here
    // also.
    glcd_command(GLCD_CMD_VOLUME_MODE);
    glcd_command(31);

    // Reset start position to the top
    glcd_command(GLCD_CMD_DISPLAY_START);

    // Turn the display on
    glcd_command(GLCD_CMD_DISPLAY_ON);

    // Unselect the chip
    output_high(GLCD_CS1);
}

void glcd_data(unsigned char data) {
   int n;

    // A0 is high for display data
    output_high(GLCD_A0);

    // Select the chip
    output_low(GLCD_CS1);

    for (n = 0; n < 8; n++) {

        if (data & 0x80) {
            output_high(GLCD_SDA);
        } else {
            output_low(GLCD_SDA);
        }

        // Pulse SCL
        output_high(GLCD_SCL);
        output_low(GLCD_SCL);

        data <<= 1;
    }

    // Unselect the chip
    output_high(GLCD_CS1);

}

void glcd_command(char command) {
   int n;

    // A0 is low for command data
    output_low(GLCD_A0);

    // Select the chip
    output_low(GLCD_CS1);

    for (n = 0; n < 8; n++) {

        if (command & 0x80) {
            output_high(GLCD_SDA);
        } else {
            output_low(GLCD_SDA);
        }

        // Pulse SCL
        output_high(GLCD_SCL);
        output_low(GLCD_SCL);

        command <<= 1;
    }

    // Unselect the chip
    output_high(GLCD_CS1);
}

void glcd_flip_screen(unsigned char flip) {
    if (flip) {
        glcd_command(GLCD_CMD_HORIZONTAL_NORMAL);
        glcd_command(GLCD_CMD_VERTICAL_REVERSE);
        glcd_flipped = 0;
    } else {
        glcd_command(GLCD_CMD_HORIZONTAL_REVERSE);
        glcd_command(GLCD_CMD_VERTICAL_NORMAL);
        glcd_flipped = 1;
    }
}

void glcd_inverse_screen(unsigned char inverse) {
    if (inverse) {
        glcd_command(GLCD_CMD_DISPLAY_REVERSE);
    } else {
        glcd_command(GLCD_CMD_DISPLAY_NORMAL);
    }
}

void glcd_test_card() {   
   int n;
    unsigned char p = 0xF0;

    for (n = 1; n <= (SCREEN_WIDTH * SCREEN_HEIGHT / 8); n++) {
        glcd_buffer[n - 1] = p;

        if (n % 4 == 0) {
            unsigned char q = p;
            p = p << 4;
            p |= q >> 4;
        }
    }

    glcd_refresh();
}

void glcd_contrast(char resistor_ratio, char contrast) {
    if (resistor_ratio > 7 || contrast > 63) return;

    glcd_command(GLCD_CMD_RESISTOR | resistor_ratio);
    glcd_command(GLCD_CMD_VOLUME_MODE);
    glcd_command(contrast);
}


st7565.h
Code:
/**
 * @file   st7565.h
 * @author David <david@edeca.net>
 * @date   November, 2011
 * @brief  Header for ST7565 graphic LCD library.
 * @sa     <a href="http://XXXXX">ST7565 command reference</a>
 * @sa     <a href="http://edeca.net/wp/electronics/the-st7565-display-controller/">My ST7565 introduction blog</a>
 * @sa     <a href="http://www.ladyada.net/learn/lcd/st7565.html">Adafruit tutorial</a>
 * @details
 *
 * A library for using the ST7565 graphic LCD in serial (software SPI) mode.
 *
 * This library is a low-level interface to the screen only.  Graphics functions (text, images
 * etc) are separate.
 *
 * Each screen requires different settings for brightness (the "volume control" and internal
 * resistor settings).  The initialisation code picks a middle ground, but you may need to
 * modify this.
 *
 * In serial mode it is not possible to read data back from the screen, meaning we
 * need an array to hold the current data.  For a 128*64 screen, this will require
 * 1KiB of RAM.  We need to know what data is currently on the screen so that we can overlay
 * new pixels onto it, so must keep a copy in local memory.
 *
 * SPI timings have been checked using the MPLAB Simulator, with Vcc of 3.3v it is impossible
 * to violate the datasheet guidelines even up to 64Mhz.
 *
 * This code has been tested on a PIC 18F26K20 at 64Mhz using the internal PLL.  No
 * adverse effects were noticed at this speed.  You will need the HiTech delay routines
 * or an equivalent.
 *
 * Example usage (initialisation):
 * @code
 *    // Initialise the screen, turning it on
 *    glcd_init();
 *
 *    // Clear the screen's internal memory
 *    glcd_blank();
 *
 *    // Set the screen's brightness, if required.  See below for information
 *    // on how this works.
 *    glcd_contrast(3, 25);
 * @endcode
 *
 * Example usage (writing to the screen):
 * @code
 *    // Set some pixels in the RAM buffer
 *    glcd_pixel(1, 1, 1);
 *    glcd_pixel(2, 1, 1);
 *    glcd_pixel(1, 2, 1);
 *    glcd_pixel(2, 2, 1);
 *
 *    // Clear a pixel in the RAM buffer
 *    glcd_pixel(64, 64, 0);
 *
 *    // Copy the RAM buffer to the screen
 *    glcd_refresh();
 * @endcode
 *
 * @note This is a low level library only, with support for setting & clearing pixels.  For text
 * or graphics functions, please see my graphics library.
 *
 * This code is released under the BSD license.  Please see BSD-LICENSE.TXT for more information.
 *
 * @todo Check timings compared to datasheet, supply a max recommended Fosc.
 * @todo Handle different sized screens if appropriate, e.g. 128*32 (some code is still
 *       fixed to certain screen/page sizes).
 */
#ifndef _ST7565_H_
#define _ST7565_H_

/** Command: turn the display on */
#define GLCD_CMD_DISPLAY_ON       0b10101111
/** Command: turn the display off */
#define GLCD_CMD_DISPLAY_OFF       0b10101110

/** Command: set all points on the screen to normal. */
#define GLCD_CMD_ALL_NORMAL         0b10100100
/** Command: set all points on the screen to "on", without affecting
             the internal screen buffer. */
#define GLCD_CMD_ALL_ON            0b10100101

/** Command: disable inverse (black pixels on a white background) */
#define GLCD_CMD_DISPLAY_NORMAL      0b10100110
/** Command: inverse the screen (white pixels on a black background) */
#define GLCD_CMD_DISPLAY_REVERSE   0b10100111

/** Command: set LCD bias to 1/9th */
#define GLCD_CMD_BIAS_9            0b10100010
/** Command: set LCD bias to 1/7th */
#define GLCD_CMD_BIAS_7            0b10100011

/** Command: set ADC output direction to normal. */
#define GLCD_CMD_HORIZONTAL_NORMAL   0b10100000
/** Command: set ADC output direction reverse (horizontally flipped).
             Note that you should use the glcd_flip_screen function so that
             the width is correctly accounted for. */
#define GLCD_CMD_HORIZONTAL_REVERSE   0b10100001

/** Command: set common output scan direction to normal. */
#define GLCD_CMD_VERTICAL_NORMAL   0b11000000
/** Command: set common output scan direction to reversed (vertically flipped). */
#define GLCD_CMD_VERTICAL_REVERSE   0b11001000

/** Command: select the internal power supply operating mode. */
#define GLCD_CMD_POWER_CONTROL      0b00101000

/** Command: set internal R1/R2 resistor bias (OR with 0..7) */
#define GLCD_CMD_RESISTOR         0b00100000
/** Command: enter volume mode, send this then send another command
             byte with the contrast (0..63).  The second command
          must be sent for the GLCD to exit volume mode. */
#define GLCD_CMD_VOLUME_MODE      0b10000001

#define GLCD_CMD_DISPLAY_START      0b01000000

/** Command: set the least significant 4 bits of the column address. */
#define GLCD_CMD_COLUMN_LOWER      0b00000000
/** Command: set the most significant 4 bits of the column address. */
#define GLCD_CMD_COLUMN_UPPER      0b00010000
/** Command: Set the current page (0..7). */
#define GLCD_CMD_SET_PAGE         0b10110000

/** Command: software reset (note: should be combined with toggling GLCD_RS) */
#define GLCD_CMD_RESET            0b11100010

/** Command: no operation (note: the datasheet suggests sending this periodically
             to keep the data connection alive) */
#define   GLCD_CMD_NOP            0b11100011

/**
 * Initialise the screen.  This should be called first.
 */
void glcd_init();
/**
 * Send a command byte to the screen.  See GLCD_CMD_ constants for
 * a list of commands.
 */
void glcd_command(char);
/**
 * Send a data byte to the screen.
 */
void glcd_data(char);
/**
 * Update the screen with the contents of the RAM buffer.
 */
void glcd_refresh();
/**
 * Clear the screen, without affecting the buffer in RAM.
 *
 * Useful at startup as the memory inside the screen may
 * contain "random" data.
 */
void glcd_blank();
/**
 * Set a single pixel
 *
 * @param x       The x position, from 1 - SCREEN_WIDTH
 * @param y       The y position, from 1 - SCREEN_HEIGHT
 * @param colour    0 = OFF, any other value = ON
 */
void glcd_pixel(unsigned char x, unsigned char y, unsigned char colour);
/**
 * Flip the screen in the alternate direction vertically.
 *
 * Can be used if the screen is mounted in an enclosure upside
 * down.
 */
void glcd_flip_screen(unsigned char flip);
/**
 * Inverse the screen, swapping "on" and "off" pixels.
 *
 * This does not affect the RAM buffer or the screen memory, the controller
 * is capable of reversing pixels with a single command.
 */
void glcd_inverse_screen(unsigned char inverse);
/**
 * Fill the local RAM buffer with a test pattern and send it to the screen.
 *
 * Useful for ensuring that the screen is receiving data correctly or for
 * adjusting contrast.
 */
void glcd_test_card();
/**
 * Set the contrast of the screen.  This involves two steps, setting the
 * internal resistor ratio (R1:R2) and then the contrast.
 *
 * Tip: Find a resistor ratio that works well with the screen and stick to it
 *      throughout.  Then adjust the contrast dynamically between 0 and 63.
 *
 * @param resistor_ratio   Ratio of the internal resistors, from 0-7
 * @param contrast         Contrast, from 0-63
 */
void glcd_contrast(char resistor_ratio, char contrast);

/** Global variable that tracks whether the screen is the "normal" way up. */
unsigned char glcd_flipped = 0;

#endif // _ST7565_H_


st7565-config.h
Code:
// Setup for ST7565R in SPI mode
/** The chip select pin */
#define GLCD_CS1 PIN_A1
/** The reset pin (this is required and should not be tied high) */
#define GLCD_RESET PIN_A2
/** The A0 pin, which selects command or data mode */
#define GLCD_A0 PIN_A0
/** The clock pin */
#define GLCD_SCL PIN_C3
/** The data pin */
#define GLCD_SDA PIN_C4

/** Screen width in pixels (tested with 128) */
#define SCREEN_WIDTH 128
/** Screen height in pixels (tested with 64) */
#define SCREEN_HEIGHT 64

/** Define this if your screen is incorrectly shifted by 4 pixels */
#define ST7565_REVERSE

/** By default we only write pages that have changed.  Undefine this
    if you want less/faster code at the expense of more SPI operations. */
//#undef ST7565_DIRTY_PAGES 1



main.c
Code:
#include "18F2520.h"
#fuses INTRC_IO      // Internal oscillator
#use delay(clock=4000000)      // 4Mhz

#include "st7565.h"
#include "st7565-config.h"

#include "st7565.c"

void main()
{

   setup_adc_ports(NO_ANALOGS|VSS_VDD);         // No analogs
   setup_adc(ADC_OFF|ADC_TAD_MUL_0);
   
   setup_comparator (NC_NC_NC_NC);      // Disable comparator

   glcd_init();

    delay_ms(100);

   glcd_contrast(10, 25);

   while(1)
   {
      glcd_pixel(1, 1, 1);
      glcd_pixel(2, 1, 1);
      glcd_pixel(1, 2, 1);
      glcd_pixel(2, 2, 1);

      delay_ms(1000);

      // Clear a pixel in the RAM buffer
      glcd_pixel(64, 64, 0);

      delay_ms(1000);

      glcd_refresh();
   }
}


But still display is not showing anything.
temtronic



Joined: 01 Jul 2010
Posts: 9163
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Apr 24, 2015 3:17 pm     Reply with quote

back to the basics...

1) does the PIC flash an LED at a known rate? Try coding for a 1Hz LED program, simple toggle LED, delay_ms(500); loop.

Does this work ???



Jay
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Apr 24, 2015 4:24 pm     Reply with quote

Quote:
Double checked the hardware. Connections are correct.

Post your connections between the PIC and the LCD.
hemnath



Joined: 03 Oct 2012
Posts: 241
Location: chennai

View user's profile Send private message

PostPosted: Fri Apr 24, 2015 9:22 pm     Reply with quote

@temtronic: I'll flash an LED at 1Hz rate and post the results.

@PCM: I'll draw and post the connection diagram.

Thanks for your reply.
hemnath



Joined: 03 Oct 2012
Posts: 241
Location: chennai

View user's profile Send private message

PostPosted: Sat Apr 25, 2015 2:18 am     Reply with quote

1. I have Flashed an LED with 1Hz.
2. Please check the connection diagram.

I dont know how to post a file here.
Please check the EA DOGM128X-6 graphic lcd datasheet page 4 for schematic.

Capacitors used are 1uF, 35V tantalum.
Graphic LCD – micro-controller pin
SI – PIN 15(SDI)
CLK – PIN 14(SCK)
A0 – PIN 2 (A0)
CS – PIN 3(A1)
RESET – PIN 4(A2)

Please help
Ttelmah



Joined: 11 Mar 2010
Posts: 19338

View user's profile Send private message

PostPosted: Sat Apr 25, 2015 3:18 am     Reply with quote

One screaming thing....

SDO on the PIC, connects to SDI on the display. The 'I' and the 'O' are input, and output. The output on the master connects to the input on the slave, and the output on the slave, to the input on the master.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Apr 25, 2015 11:15 am     Reply with quote

I don't think that's the problem, because he's using bit-banging to transmit
commands and data to the lcd.

I question the Tantalum capacitors. When I did a project with a "raw"
glcd, I used low ESR ceramic capacitors, per the lcd controller data sheet.
I don't know how he has connected the Tantalums, but if they are subject
to reverse voltage, they will start to decay and act like a resistor, possibly
ultimately burning up.

I am curious about the voltage on the Vout pin. Is it +12 volts, per the
data sheet ? What do you see with an oscilloscope ?

Also, you still didn't initialize GLCD_SCL. Here's the reason. PIC pins
come up out of power-on-reset as inputs. They're floating. So what
happens to your first SCL pulse ? You have a floating signal, and then
you take it high. But will that present a positive edge to the lcd controller ?
From floating to high ? Probably not.
Code:
 
// Pulse SCL
output_high(GLCD_SCL);
output_low(GLCD_SCL);

You can initialize GLCD_SCL in your glcd_init() routine, like so:
Code:

void glcd_init() {

output_low(GLCD_SCL); // Initialize SCL
output_low(GLCD_SDA); // Initialize SDA

// Select the chip
output_low(GLCD_CS1);

output_low(GLCD_RESET);

I've also initialized SDA. I think it's best that the LCD controller not have
any floating signals presented to its input pins.
hemnath



Joined: 03 Oct 2012
Posts: 241
Location: chennai

View user's profile Send private message

PostPosted: Mon Apr 27, 2015 10:26 pm     Reply with quote

Changed the capacitors to box type. Because i have it.

Measured voltage at pin 32 which is Vout = 12.47V.

But still it is not working.

voltages are measured on the LCD w.r.t ground
Pin 21: 7.58V
Pin 22: 6.75V
Pin 23: 5.90V
Pin 24: 1.703V
Pin 25: 0.853V
Pin 26: 0V
Pin 27: 1.642V
Pin 28: 7.87V
Pin 29: 4.77V
Pin 30: 1.644V
Pin 31: 10.96V
Pin 32: 12.47V
Pin 33: 0V
Pin 34: 3.3V
Pin 35: 3.3V
Pin 36: 3.3V
Pin 37: 0V
Pin 38: 0V
Pin 39: 3.3V
Pin 40: 3.3V

Why pin 38 is 0V. It should be +3.3V right?
hemnath



Joined: 03 Oct 2012
Posts: 241
Location: chennai

View user's profile Send private message

PostPosted: Tue Apr 28, 2015 11:34 pm     Reply with quote

Thanks guys for all your help. Finally i turned ON some pixels on the graphic lcd by changing some initialization commands.

How to turn 8x8 pixels ON?
How to select the page address and column address?
hemnath



Joined: 03 Oct 2012
Posts: 241
Location: chennai

View user's profile Send private message

PostPosted: Wed Apr 29, 2015 4:54 am     Reply with quote

tried the below code to clear the display. But it is not clearing completely?
Code:
void clear_screen()
{
   unsigned int16 p = 0, c = 0;

   for(p = 0; p < 8; p++)
   {
      glcd_command(0xB0 | p);

      for(c = 0; c < 129; c++)
      {
         glcd_command(0x10 | (c & 0xf));
         glcd_command(0x00 | ((c >> 4) & 0xf));
         glcd_data(0x00);
      }     
   }
}
temtronic



Joined: 01 Jul 2010
Posts: 9163
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Apr 29, 2015 5:07 am     Reply with quote

rhmm....not clearing completely...

Is only one half of the display clearing or just 'random' pixels?

I don't use that LCD module but have you got the Manufacturers datasheet for it? NOT just a 'driver' someone made? There could easily be a 'timing' issue, most LCDs need a specific MINIMUM 'startup' delay. I use 500ms. Have for 20 years and NEVER had any init issues.

If a 'section' of the display doesn't clear, I think of a bad wiring or miswired connection OR incorrect driver code.

If 'random' pixels, that's tougher, though the datasheet/mfr example code might be useful.

Also, what is the power supply? It should be rated for at least 5X the normal 'run' current AND be properly bypassed !

hth

Jay
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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