Jump to content

8bit interface


nimaltd

Recommended Posts

I use stm32f103VE in FSMC 8bit. my lcd is ili9481 in 8 bit interface. how can config my lcd ? i cant drive it .

its not work.

#define GDISP_REG              ((volatile uint16_t *) 0x60000000)[0] /* RS = 0 */
#define GDISP_RAM              ((volatile uint16_t *) 0x60FF0000)[0] /* RS = 1 */

static GFXINLINE void init_board(GDisplay *g) {
    (void) g;
  HAL_TIM_PWM_Start(&htim2,TIM_CHANNEL_2);
  
}

static GFXINLINE void post_init_board(GDisplay *g) {
    (void) g;
}

static GFXINLINE void setpin_reset(GDisplay *g, bool_t state) {
    (void) g;
    HAL_GPIO_WritePin(LCD_RST_GPIO_Port,LCD_RST_Pin,(GPIO_PinState) !state);
}

static GFXINLINE void set_backlight(GDisplay *g, uint8_t percent) {
    (void) g;
    if(percent > 99)
        percent = 99;
    htim2.Instance->CCR2 = percent;
}

static GFXINLINE void acquire_bus(GDisplay *g) {
    (void) g;
}

static GFXINLINE void release_bus(GDisplay *g) {
    (void) g;
}

static GFXINLINE void write_index(GDisplay *g, uint16_t index) {
    (void) g;
  GDISP_REG = index&0x00ff;
}

static GFXINLINE void write_data(GDisplay *g, uint16_t data) {
    (void) g;
  
  GDISP_RAM = (data>>8);
  GDISP_RAM = data&0x00ff;
}

static GFXINLINE void setreadmode(GDisplay *g) {
    (void) g;
}

static GFXINLINE void setwritemode(GDisplay *g) {
    (void) g;
}

static GFXINLINE uint16_t read_data(GDisplay *g) {
    (void) g;
  uint16_t data;

  data = (GDISP_RAM<<8);  
  data |= GDISP_RAM;

  
    return data;
}
 

Edited by nimaltd
Link to comment
Share on other sites

 FSMC_NORSRAM_TimingTypeDef Timing;

  /** Perform the SRAM1 memory initialization sequence
  */
  hsram1.Instance = FSMC_NORSRAM_DEVICE;
  hsram1.Extended = FSMC_NORSRAM_EXTENDED_DEVICE;
  /* hsram1.Init */
  hsram1.Init.NSBank = FSMC_NORSRAM_BANK1;
  hsram1.Init.DataAddressMux = FSMC_DATA_ADDRESS_MUX_DISABLE;
  hsram1.Init.MemoryType = FSMC_MEMORY_TYPE_SRAM;
  hsram1.Init.MemoryDataWidth = FSMC_NORSRAM_MEM_BUS_WIDTH_16;                               <<<< not work in 8 bit.. I dont know why. 
  hsram1.Init.BurstAccessMode = FSMC_BURST_ACCESS_MODE_DISABLE;
  hsram1.Init.WaitSignalPolarity = FSMC_WAIT_SIGNAL_POLARITY_LOW;
  hsram1.Init.WrapMode = FSMC_WRAP_MODE_DISABLE;
  hsram1.Init.WaitSignalActive = FSMC_WAIT_TIMING_BEFORE_WS;
  hsram1.Init.WriteOperation = FSMC_WRITE_OPERATION_ENABLE;
  hsram1.Init.WaitSignal = FSMC_WAIT_SIGNAL_DISABLE;
  hsram1.Init.ExtendedMode = FSMC_EXTENDED_MODE_DISABLE;
  hsram1.Init.AsynchronousWait = FSMC_ASYNCHRONOUS_WAIT_DISABLE;
  hsram1.Init.WriteBurst = FSMC_WRITE_BURST_DISABLE;
  /* Timing */
  Timing.AddressSetupTime = 2;
  Timing.AddressHoldTime = 2;
  Timing.DataSetupTime = 5;
  Timing.BusTurnAroundDuration = 0;
  Timing.CLKDivision = 2;
  Timing.DataLatency = 2;
  Timing.AccessMode = FSMC_ACCESS_MODE_B;

 

 

/////////////////////////////

 

 

    LLDSPEC    void gdisp_lld_write_color(GDisplay *g)
  {
        write_data(g, gdispColor2Native(g->p.color)>>8);
    write_data(g, gdispColor2Native(g->p.color));
    }

 

/////////////////////////////

 


static GFXINLINE void write_index(GDisplay *g, uint16_t index)
{
    (void) g;
  GDISP_REG = index;
}

static GFXINLINE void write_data(GDisplay *g, uint16_t data)
{
    (void) g;
  GDISP_RAM = data;
}
 

 

 

 

 

 

 

Link to comment
Share on other sites

9 hours ago, nimaltd said:

static GFXINLINE void write_index(GDisplay *g, uint16_t index)
{
    (void) g;
  GDISP_REG = index;
}

static GFXINLINE void write_data(GDisplay *g, uint16_t data)
{
    (void) g;
  GDISP_RAM = data;
}

You have to write (and read) two bytes here. Currently you're missing out on half of the data.

 

9 hours ago, nimaltd said:

FSMC_NORSRAM_MEM_BUS_WIDTH_16

And yes, that is definitely wrong too if you want to use the 8-bit bus.

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