STM32F4Discovery and SSD1289

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
mucka
Posts: 3
Joined: Wed Jun 12, 2013 11:07 pm

STM32F4Discovery and SSD1289

Post by mucka »

Hi, i'm new to ChibiOS, i'm trying to use it with my stm32f4discovery board and tft screen based on SSD1289 controller. As i read the best way to do this is to use fsmc protocol. I have a problem because after 2 hours of googling i didn't found any realiable interconnection schema betweent discovery board and ssd1289 screen using fsmc. The datasheets of both devices didn't help me neither. On Stm side i have 24 fsmc address pins, 16 fsmc data pins, ne, nce, noe and many more fsmc pins, but on screen side i have only 16 data pins rs, cs, rd and wr. As a beginner, i can't see the correlation, i've never used that screen before i just got it. The only hint i have is piece of code from gdisp_lld_board_st_stm32f4_discovery.h file from gfx archive:

Code: Select all

   /* set pins to FSMC mode */
   IOBus busD = {GPIOD, (1 << 0) | (1 << 1) | (1 << 4) | (1 << 5) | (1 << 7) | (1 << 8) |
                     (1 << 9) | (1 << 10) | (1 << 11) | (1 << 14) | (1 << 15), 0};

   IOBus busE = {GPIOE, (1 << 7) | (1 << 8) | (1 << 9) | (1 << 10) | (1 << 11) | (1 << 12) |
                  (1 << 13) | (1 << 14) | (1 << 15), 0};

I assume those are pins i should screen connect to, but still i do not know corrent order, and about this pins it's only my assumption. I don't know if google is making fun of me, but can anybody share the interconnection schema with me ? It may be any STM32 with fsmc schema, i just want to know what is it all about ?
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: STM32F4Discovery and SSD1289

Post by Tectu »

Hello mucka and welcome to ChibiOS!

There's a table which helps you to connect your LCD module to your microcontroller. You can find it here.


~ Tectu
mucka
Posts: 3
Joined: Wed Jun 12, 2013 11:07 pm

Re: STM32F4Discovery and SSD1289

Post by mucka »

Thank you for answer ! Table was helpful, don't know how could I miss it, but still i'm not able to draw anything on the screen, i've connected everything according to a table, and nothing appears on screen, i'm using following program:

Code: Select all

#include "ch.h"
#include "hal.h"
#include "gfx.h"

static WORKING_AREA(waThread1, 128);
static msg_t Thread1(void *arg) {

  (void)arg;
  chRegSetThreadName("blinker");
  while (TRUE) {
    palSetPad(GPIOD, GPIOD_LED3);       /* Orange.  */
    chThdSleepMilliseconds(500);
    palClearPad(GPIOD, GPIOD_LED3);     /* Orange.  */
    chThdSleepMilliseconds(500);
  }
  return 0;
}


int main(void) {
  coord_t w, h;

  halInit();
  chSysInit();
  gfxInit();

  chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
 
  w = gdispGetWidth();
  h = gdispGetHeight();

  while (TRUE) {
    chThdSleepMilliseconds(500);
    gdispDrawBox(10,10, w/2, h/2, Yellow);
    gdispFillArea(w/2, h/2, w/2-10, h/2-10, Blue);
  }
  return 0;
}

following gfxconf.h file:

Code: Select all

#define _GFXCONF_H

/* The operating system to use - one of these must be defined */
#define GFX_USE_OS_CHIBIOS      TRUE
#define GFX_USE_OS_WIN32      FALSE
#define GFX_USE_OS_POSIX      FALSE

/* GFX sub-systems to turn on */
#define GFX_USE_GDISP         TRUE

/* Features for the GDISP sub-system. */
#define GDISP_NEED_VALIDATION   TRUE
#define GDISP_NEED_CLIP         TRUE
#define GDISP_NEED_TEXT         FALSE
#define GDISP_NEED_CIRCLE      FALSE
#define GDISP_NEED_ELLIPSE      FALSE
#define GDISP_NEED_ARC         FALSE
#define GDISP_NEED_SCROLL      FALSE
#define GDISP_NEED_PIXELREAD   FALSE
#define GDISP_NEED_CONTROL      FALSE
#define GDISP_NEED_MULTITHREAD   FALSE
#define GDISP_NEED_ASYNC      FALSE
#define GDISP_NEED_MSGAPI      FALSE

Makefile, chconf.h halconf.h and mcuconf.h i took from stm32f4discovery example. I have checked all the interconnections using multimeter and they are ok. Am i missing something ? Screen is empty(white) and ! after adding gdispDrawBox and gdispFillArea to the main loop i noticed strange leds behaviour. Orange led which should blink is blinking ok, but 2 additional leds have very short blink every 500 milliseconds, seems like those functions are sending some signal through them ?? I have strange feeling i'm still missing something obvious. Would somebody like to help ?

Edit: Ok i found out why leds are blinking, 2 of them share ports with fsmc, that's mean data is transmitted, but screen is still empty.
Eddie
Posts: 44
Joined: Sat Mar 16, 2013 5:57 pm
Has thanked: 2 times
Been thanked: 6 times

Re: STM32F4Discovery and SSD1289

Post by Eddie »

I tried your code, it works without problem for me - STM32F4 Discovery and TFT HY32C with SSD1289.

Try change the FSMC timing in drivers/gdisp/SSD1289/gdisp_lld_board_st_stm32f4_discovery.h
from:

Code: Select all

/* FSMC timing */
   FSMC_Bank1->BTCR[FSMC_Bank+1] = FSMC_BTR1_ADDSET_0 | FSMC_BTR1_DATAST_2 | FSMC_BTR1_BUSTURN_0 ;

to:

Code: Select all

/* FSMC timing */
      FSMC_Bank1->BTCR[FSMC_Bank+1] = FSMC_BTR1_ADDSET_3 | FSMC_BTR1_DATAST_3 | FSMC_BTR1_BUSTURN_0 ;

mucka
Posts: 3
Joined: Wed Jun 12, 2013 11:07 pm

Re: STM32F4Discovery and SSD1289

Post by mucka »

Tried this and effect still the same, screen is plain white. I've borrowed another discovery board, connected all pins one more time, checked connection with multimeter but effect still the same. In one of pin review i found out i've forgot about reset pin, connected it to 3V source on discovery but effect still the same, then connected it to the gpio and set 0 and 1 ( i know it should be 1 but i tried everything ), but nothing changed, even if i changed state on gpio before gfxInit(). If you are saying that my code is ok, i'm sure that my connection match that in gfx page, the only cause left is screen corrupted. It's cheap chinese YX32B model from ebay so i should't be surprised :P Or mayby i still do not understand something fundamental, but anyway, this is enough for now. Thanks for your time !

I have one more question, maybe not related to the topic, but not worth new topic, I pulled out of the drawer old alphanumeric lcd, because i still wanted to play some with ChibiOS, and I came across not clear for me behavior. When I initialize, in beginning of main function, gfx library using 'gfxInit()' while compiling i see

Code: Select all

Linking build/ch.elf
build/obj/gfx.o: In function `gfxInit':
/home/mucka/Software/ChibiOS_2.6.0/ext/gfx/src/gfx.c:96: undefined reference to `_tdispInit'
collect2: error: ld returned 1 exit status

but, when i change it to 'tdispInit()' problem disappear and everything works fine on hardware :?: I'm confused now i shouldn't use gfxInit or this is only case of tdisp module ?
Post Reply