Jump to content

Difficulty with Sharp LCD


zump

Recommended Posts

I am trying to get the Sharp LCD LS010B7DH01 working with uGFX, ChibiOS 2.6.1 and STM32L151CB. It is quite a basic display. There are no special features, and one can write lines to the memory with the following SPI bytestream.

Write command byte, line address, 16 bytes of pixel data, 2 dummy bytes. http://www.avnet-embedded.eu/fileadmin/user_upload/Files/Displays/Mono/Sharp_LS010B7DH01.pdf (Datasheet)

Here are relevant excerpts from gdisp_lld_*.c


/*===========================================================================*/
/* Driver local definitions. */
/*===========================================================================*/

#ifndef GDISP_SCREEN_HEIGHT
#define GDISP_SCREEN_HEIGHT 128 // This controller should support 32 (untested) or 64
#endif
#ifndef GDISP_SCREEN_WIDTH
#define GDISP_SCREEN_WIDTH 128
#endif


#define LS010_LINE_WIDTH GDISP_SCREEN_WIDTH/8

#define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER<<0)

#include "LS010.h"

/*===========================================================================*/
/* Driver local functions. */
/*===========================================================================*/

// Some common routines and macros
#define RAM(g) ((uint8_t *)g->priv)

// Some common routines and macros
#define delay(us) gfxSleepMicroseconds(us)
#define delayms(ms) gfxSleepMilliseconds(ms)

#define xyaddr(x, y) (x + y * GDISP_SCREEN_WIDTH) / 8
#define xybit(x, y) (1 << ((x + y * GDISP_SCREEN_WIDTH) % 8))
/*===========================================================================*/
/* Driver exported functions. */
/*===========================================================================*/

LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
// The private area is the display surface.
g->priv = gfxAlloc(2048);

lcd_init(&handle_lcd); // <--- My initialisation function which successfully turns LCD on

acquire_bus(g);

// Finish Init
post_init_board(g);

// Release the bus
release_bus(g);

/* Initialise the GDISP structure */
g->g.Width = GDISP_SCREEN_WIDTH;
g->g.Height = GDISP_SCREEN_HEIGHT;
g->g.Orientation = GDISP_ROTATE_0;
g->g.Powermode = powerOn;
g->g.Backlight = GDISP_INITIAL_BACKLIGHT;
g->g.Contrast = GDISP_INITIAL_CONTRAST;
return TRUE;
}

#if GDISP_HARDWARE_FLUSH
LLDSPEC void gdisp_lld_flush(GDisplay *g) {
unsigned i;
uint8_t j = 128; //Address

// Don't flush if we don't need it.
if (!(g->flags & GDISP_FLG_NEEDFLUSH))
return;

for(i=0; i < 2048; i += LS010_LINE_WIDTH)
{
write_data(g, RAM(g)+i, LS010_LINE_WIDTH, j);
j--;
}
}
#endif

#if GDISP_HARDWARE_DRAWPIXEL
LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) {
coord_t x, y;
int tmpx = xyaddr(g->p.x, g->p.y);
int bit = xybit(g->p.x,g->p.y);

switch(g->g.Orientation) {
default:
case GDISP_ROTATE_0:
x = g->p.x;
y = g->p.y;
break;
case GDISP_ROTATE_90:
x = g->p.y;
y = GDISP_SCREEN_HEIGHT-1 - g->p.x;
break;
case GDISP_ROTATE_180:
x = GDISP_SCREEN_WIDTH-1 - g->p.x;
y = GDISP_SCREEN_HEIGHT-1 - g->p.y;
break;
case GDISP_ROTATE_270:
x = GDISP_SCREEN_HEIGHT-1 - g->p.y;
x = g->p.x;
break;
}
if (gdispColor2Native(g->p.color) != Black)
{
RAM(g)[xyaddr(x, y)] &= xybit(x,y);
}else {
RAM(g)[xyaddr(x, y)] |= ~xybit(x,y);
g->flags |= GDISP_FLG_NEEDFLUSH;
}
}
#endif

and and board_*.h


static uint8_t reverse(uint8_t b) {
b = (b & 0xF0) >> 4 | (b & 0x0F) << 4;
b = (b & 0xCC) >> 2 | (b & 0x33) << 2;
b = (b & 0xAA) >> 1 | (b & 0x55) << 1;
return b;
}

static inline void write_data(GDisplay *g, uint8_t* data, uint16_t length, uint8_t addr) {
(void) g;

uint8_t tmp[20] = {0}; // Command to write + address + 16 byte pixel data + 2 dummy bytes
tmp[0] = 0b10000000; // Command to write
tmp[1] = reverse(addr); // LSB first

memmove(tmp+2, data, 16);

spiUnselect(&SPID1);
chThdSleepMicroseconds(SCS_HIGH_DELAY);
spiSend(&SPID1, 20, tmp);
chThdSleepMicroseconds(SCS_LOW_DELAY);
spiSelect(&SPID1);
chThdSleepMicroseconds(INTERFRAME_DELAY);
}

However, I am not able to get correct output. For example, here is the output when running the 'basics' example.

mZdT8Hc.jpg

Can anyone see something wrong here?

Link to comment
Share on other sites

I'm seeing several things there that are not the way they are supposed to be (not in any order of importance):

  • What is handle_lcd? Refering to your lcd_init(&handle_lcd);
  • You never call the board_init(). This is the place where you are supposed to set up your pin configuration and other peripherals.
  • You do not reset your display after you called your board_init() (which you currently don't).
  • Even if your LCD does require a non-value based initialisation, it's supposed to be inside gdisp_lld_init(). If you need to set different pins like the enable one, just add those calls to the board file. The driver must be as generic as possible.
  • The command byte to draw a line is supposed to be send through the write_cmd() call in your board file. Please refer to the SSD1306 driver to see how it's supposed to be done properly.
  • In your write_data() routine, you unselect the SPI slave, write to it and then select it. It's supposed to be the other way around. Please refer to the ChibiOS/RT HAL documentation for further information.

All of the points above are without looking at your actual algorithms or the datasheet. Please check those points first (most likely they won't solve your issue, but it's hard to debug your code in this "messy" state).

I suggest you to take a close look the the existing SSD1306 driver as that one is VERY similar to yours. You shouldn't have to change a lot from there.

~ Tectu

Link to comment
Share on other sites

  • 2 weeks later...
  • 4 months later...

to zump

Dear zump

I have some asking to you about Sharp LS010B7DH01

I saw your picture on this forum and it seems that your display have got more quality white colore then mine

Can I ask you to do fotos when its works and not under normal light?

Link to comment
Share on other sites

Dear zump

I have some asking to you about Sharp LS010B7DH01

I saw your picture on this forum and it seems that your display have got more quality white colore then mine

Can I ask you to do fotos when its works and not under normal light?

I recommend you to send a private message to zump so he gets an e-mail notification. You can do that by clicking on the username.

~ Tectu

Link to comment
Share on other sites

  • 3 years later...

Hello @umitgun and welcome to the µGFX community!

Could you do me a favor and simply creating a new topic that contains all the information about what exactly you're working with (exact display controller/driver type, what microcontroller, what underlying system (eg. baremetal or which RTOS), your driver and everything else that would help us resolving your problem. Don't forget a detailed description of what the problem actually is :)

Looking forward helping you resolving your problem.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...