Jump to content

Configuring uGFX for SSD1289


ep.hobbyiest

Recommended Posts

Hi,

I have some doubt from SSD1289 board file. I have TFT_320QVT lcd which has ssd1289 controller in it.
I copied SSD1289 driver folder in project.

But i am little confused about pin configuration and interface. 

I have enabled DMA here. So, will it cause double writing on PORT or something.

We are writing data to memory location. So, FSMC will take case of that or DMA will take care. 
 

static GFXINLINE void init_board(GDisplay *g) {
  /*
   * As we are not using multiple displays we set g->board to NULL as we don't
   * use it.
   */
//  g->board = 0;
//
//  switch(g->controllerdisplay) {
//  /*
//   * Set up for Display 0
//   */
//  case 0:
    /* FSMC setup for F1 */
    rccEnableAHB(RCC_AHBENR_FSMCEN, 0);

    /* Group pins for FSMC setup as alternate function */
    IOBus busD = { GPIOA, (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 };

    /* FSMC sa alternate function */
    palSetBusMode(&busD, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
    palSetBusMode(&busE, PAL_MODE_STM32_ALTERNATE_PUSHPULL);

    /*
     * NOTE: stm32F10x.h is FAULTY on FSMC
     * NOTE: Used hardcore bit shifting below
     * NOTE: All timings for 72MHz HCLK - should be revised for lower HCLK
     */

    /* FSMC timing - Read: DATAST = 0x20; all the rest = 0.
     * 100ns cycle time for SSD1289 as per DataSheet
     */
    FSMC_Bank1->BTCR[FSMC_BANK+1] = (0x20 << 8);

    /* FSMC timing - Write: DATAST = 0x01, ADDSET = 0x01 all the rest = 0.
     * 1000ns cycle time for SSD1289 as per DataSheet
     */
    FSMC_Bank1E->BWTR[FSMC_BANK] = (0x1 << 8) | (0x01 << 0);

    /* Bank1 NOR/SRAM control register configuration
     * Note: different read and write cycle timing
     */
    FSMC_Bank1->BTCR[FSMC_BANK] = FSMC_BCR1_MWID_0 | FSMC_BCR1_WREN |          \
        FSMC_BCR1_MBKEN | FSMC_BCR1_EXTMOD;

    /* DMA Setup. */
#if defined(GDISP_USE_DMA) && defined(GDISP_DMA_STREAM)
    if (dmaStreamAllocate(GDISP_DMA_STREAM, 0, 0, 0))
      gfxExit();

    dmaStreamSetMemory0(GDISP_DMA_STREAM, &GDISP_RAM);
    dmaStreamSetMode(GDISP_DMA_STREAM, STM32_DMA_CR_PL(0) |                    \
                     STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD |     \
                     STM32_DMA_CR_DIR_M2M);
#endif

    /* Display backlight control */
    /* TIM3 ch2 (PB5) connected to LCD BL_CNT */
    pwmStart(&PWMD3, &pwmcfg);
    palSetPadMode(GPIOB, 5, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
    pwmEnableChannel(&PWMD3, 1, 100);

//    break;
//  }
}

Here is picture of lcd i have. 

http://obrazki.elektroda.pl/6457813100_1494433917.jpg

And i have updated code on github . https://github.com/ugfx/ssd1289 

Thanks.

Link to comment
Share on other sites

17 minutes ago, ep.hobbyiest said:

And i have updated code on github . https://github.com/ugfx/ssd1289 

Please delete that organization on github immediately. It is very misleading and careless of you to create an organization on github with the name of a company you're not involved in. This can lead to serious problems for all parties (you, us and users & customers that might get wrong code & information from there).

Link to comment
Share on other sites

I'd strongly recommend you to try everything without DMA first. Once you have that working, you can start dicking around with that.

It has been a long time since I last looked at the SSD1289 driver (in fact, that is the driver that made me start writing µGFX back in the day) but I am pretty sure that the driver works well. It is definitely taken care of by the driver that there are no double writes or anything like that.

Link to comment
Share on other sites

Hi,
I was trying without DMA and with following interface connection. 

 * PD0  - Alternate PP 50M (FSMC_DB2)
 * PD1  - Alternate PP 50M (FSMC_DB3)

 * PD4  - Alternate PP 50M (TFT_RD)
 * PD5  - Alternate PP 50M (TFT_WR)
 
 * PD7  - Alternate PP 50M (TFT_CS)
 * PD8  - Alternate PP 50M (FSMC_DB13)
 * PD9  - Alternate PP 50M (FSMC_DB14)
 * PD10 - Alternate PP 50M (FSMC_DB15)
 * PD11 - Alternate PP 50M (TFT_RS - Data/Command)
 * PD12 - Alternate PP 50M (PWM2 CON3.3 TIM4_CH1)
 * PD13 - PP output 50M    (LED3)
 * PD14 - Alternate PP 50M (FSMC_DB0)
 * PD15 - Alternate PP 50M (FSMC_DB1)
 
 * PE7  - Alternate PP 50M (FSMC_DB4)
 * PE8  - Alternate PP 50M (FSMC_DB5)
 * PE9  - Alternate PP 50M (FSMC_DB6)
 * PE10 - Alternate PP 50M (FSMC_DB7)
 * PE11 - Alternate PP 50M (FSMC_DB8)
 * PE12 - Alternate PP 50M (FSMC_DB9)
 * PE13 - Alternate PP 50M (FSMC_DB10)
 * PE14 - Alternate PP 50M (FSMC_DB11)
 * PE15 - Alternate PP 50M (FSMC_DB12)
 
 * PB11 - RESET
 


 I flashed the code but nothing is working. I checked the connection but it seems to be fine. I am blinking led at 500ms periodicity and it is blinking. Means there is no stuck. 
 Here is my observation,
 No Backlight,
 RESET,CS,RS,RW,RD pins were HIGH(+3.3V). But there was no voltage on DATA pins. 
 What could be the reason. 
 

Link to comment
Share on other sites

Looking at the initialization code in your first code it seems like your pins are not being initialized corresponding to the list that you just posted.

IOBus busD = { GPIOA, (1 << 0) | (1 << 1) | (1 << 4) | (1 << 5) |          \
  (1 << 7) | (1 << 8) | (1 << 9) | (1 << 10) | (1 << 11) |    \
  (1 << 14) | (1 << 15), 0 };

There are a whole lot of pins being configured on PORTA but you don't seem to have any pins connected to port A. It might be confusing because the struct instance is called busD instead of busA :D 
Go through all pins and make sure that the board_init() function initializes them properly.

Link to comment
Share on other sites

Hi,

Any suggestion, I have updated my code and following my observation. 

Controller is not stuck anywhere it is blinking led continously.

RS,RD,WR , D0-D15 volatge- Still no data

RESET - 3.3

CS - 3.3 For my lcd there are two CS pins and names are as CS and F_CS.  Here i am confused. I tried on both pins but none of them is working.

Here is my lcd pic.

http://obrazki.elektroda.pl/6457813100_1494433917.jpg

 

Any suggest can help. No clue to proceed further.

Link to comment
Share on other sites

3 hours ago, ep.hobbyiest said:

there are two CS pins and names are as CS and F_CS.  Here i am confused.

You must use the CS-pin. the F_CS is acturally T_CS which is used for the touchscreen of the display.

As for your code there is an example in boards/addons/gdisp for your driver which has a slightly different configuration than yours. Maybe try those settings out also and see if it gives any difference?

Link to comment
Share on other sites

21 hours ago, cpu20 said:

As for your code there is an example in boards/addons/gdisp for your driver which has a slightly different configuration than yours. Maybe try those settings out also and see if it gives any difference?

Yeah, I changed the file little bit. 

Change 1:
Here i was getting error for structure pointer of GDisplay type. so, i commented that part. Following is the error.

In file included from main.c:20:0:
board_SSD1289.h: In function 'init_board':
board_SSD1289.h:60:4: error: dereferencing pointer to incomplete type
   g->board = 0;
    ^


    
    Change 2:
And next different is in function of setpin_reset where i am setting or clearing RESET pin. Following is my change.

static GFXINLINE void setpin_reset(GDisplay *g, bool_t state) {
  (void) g;

  if(state)
    palClearPad(GPIOB, 11);
  else
    palSetPad(GPIOB, 11);//todo: define pins tft
}

Change 3:
I am using  TM3 ch2 for Backlight instead of TM3 CH3. TM3 CH3 is used in boards/addons/gdisp/board_SSD1289_stm32f4discovery.h file. 
 

I can try reverting change 2 and 3 but i try to resolve the error in Change 1 but i couldn't. 

Edited by ep.hobbyiest
Link to comment
Share on other sites

Your FSMC initialisation doesn't look quite right; for the SSD1963 I had the following as your lines 77, 78:

		/* FSMC is an alternate function 12 (AF12) */
		palSetBusMode(&busD, PAL_MODE_ALTERNATE(12));
		palSetBusMode(&busE, PAL_MODE_ALTERNATE(12));

 

Link to comment
Share on other sites

2 hours ago, steved said:

Your FSMC initialisation doesn't look quite right; for the SSD1963 I had the following as your lines 77, 78:


		/* FSMC is an alternate function 12 (AF12) */
		palSetBusMode(&busD, PAL_MODE_ALTERNATE(12));
		palSetBusMode(&busE, PAL_MODE_ALTERNATE(12));

 

In this case I don't think that will help much as he is using a STM32F1xx target and it only has one alternate function.

@ep.hobbyiest You should keep the second and third change if you changed the pin configurrations in your application.
That error you are getting is a problem though. It could indicate that something is wrong with your configuration and that not all the correct files are included.
Are you using the Makefile approach or the 'single file inclusion mechanism'? And what IDE are you using?

Link to comment
Share on other sites

In your makefile you specify OPT_CPU = stm32m1, but this should be stm32m3. In your main file you do not need to include:

#include "board_SSD1289.h"
#include "ginput_lld_toggle_board.h"

What version of the ugfx library are you using?

Link to comment
Share on other sites

Was your backlight not working from the start? Because that needs to be fixed before you can see anything draw on the screen.

Looking at your previous post you connected the backlight pin to PD12 (TIM4_CH1)? If I am not mistaken you should change the following in your code:

static const PWMConfig pwmcfg =
{
 100000,   // frequency
 100,      // period
 NULL,     // callback
 {
  {PWM_OUTPUT_ACTIVE_HIGH, 0},
  {PWM_OUTPUT_DISABLED, 0},
  {PWM_OUTPUT_DISABLED, 0},
  {PWM_OUTPUT_DISABLED, 0}
 },
 0,        // cr2
 0,        // dier
};

pwmStart(&PWMD4, &pwmcfg);
pwmEnableChannel(&PWMD4, 1, 100);

If this is set up correctly you should see the backlight come on after the gfxInit() in your code.

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...