cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 Discovery + LCD + MISSING PIN??

regiuliano2009
Associate II
Posted on May 15, 2012 at 17:40

Hi all,

I'm trying to add an LCD screen to my discovery. I have bought one from ITEASTUDIO (http://iteadstudio.com/store/index.php?main_page=product_info&cPath=18&products_id=538)

I'm modifing the stm324xg_eval_lcd.c but I have a doubt!! In the function LCD_CtrlLinesConfig in the SRAM Address lines configuration it uses the PF0 pin as address pin (and from EVAL user manual FSMC_A0)  but in my discovery I don't have any FSMC_A0!!! Only, FSMC_A16, etc...

Can I use this pin (FSMC_A16) as my FSMC_A0 address or is it a problem to drive the TFT_RS pin of my lcd??

thanks!

C

#lcd-stm32f4discovery
12 REPLIES 12
regiuliano2009
Associate II
Posted on May 18, 2012 at 10:58

Dear a.rocchegiani,

thanks for the suggestions!!

I have set my lcd offset accordingly to A.Paiva post (#define LCD_BASE ((uint32_t)(0x60000000 | 0x08000000 | 0x00000001<<16)))

Then I can't read any data from the device because I have only CS, WR, RS pin going out my LCD.

Also, my lcd as a 8 bit interface (ILI9325 controller) so, may be, that's the problem? I need an LCD with 16 bit pinout?

a_rocchegiani
Associate II
Posted on May 18, 2012 at 19:45

Hi,

FSMC can manage either 8 bit or 16 bit data.

If you starting from STM324xg_eval_lcd.c, I suggest you some starter point to try with your ILI9325/8 bit TFT

1) Remove R50 to avoid FSMC_NWE conflict with USB overcurrent chip output

2) insert this line at begin to write register in your base address and data 64Kbyte later (A16 go high only when you write data and stay low when you write reg)  

__IO uint8_t * LCD_LCD_REG=0x68000000;

__IO uint8_t * LCD_LCD_RAM=0x68010000; //A16 <->RS pin: adding 64Kbytes

3) split low level write function into 8 bit (MSByte first)

void LCD_WriteReg(uint8_t LCD_Reg, uint16_t LCD_RegValue)

{

  /* Write 16-bit Index, then Write Reg */

  *LCD_LCD_REG = 0;

  *LCD_LCD_REG = LCD_Reg;

  /* Write 16-bit Reg */

  *LCD_LCD_RAM = (uint8_t)(LCD_RegValue>>8);

  *LCD_LCD_RAM = (uint8_t)(LCD_RegValue & 0xff);

}

void LCD_WriteRAM_Prepare(void)

{

  *LCD_LCD_REG = 0;

  *LCD_LCD_REG = LCD_REG_34;

}

void LCD_WriteRAM(uint16_t RGB_Code)

{

  /* Write 16-bit GRAM Reg */

  *LCD_LCD_RAM = (uint8_t) (RGB_Code>>8);

  *LCD_LCD_RAM = (uint8_t) (RGB_Code & 0xff);

}

4) Kill any read attempt: example for STM324xG_LCD_Init

void STM324xG_LCD_Init(void)

{

  __IO uint32_t lcdid = 0;

 

/* Configure the LCD Control pins --------------------------------------------*/

  LCD_CtrlLinesConfig();

/* Configure the FSMC Parallel interface -------------------------------------*/

  LCD_FSMCConfig();

  _delay_(5); /* delay 50 ms */

  /* Read the LCD ID */

  lcdid = LCD_ReadReg(0x00);  ####### this line is to kill !!!!  #####

Force the init 9325 sequence with:

  lcdid=0x9325;  //lcdid = LCD_ReadReg(0x00);  #### we have a ILI9325 chip (?) ####

Enjoy !!

Alessandro.

mlrogers2002
Associate II
Posted on May 20, 2012 at 01:25

Try using 0x60020000 for A_16. The deal is, A[24:0] gets HADDR[25:1] in 16 bit address mode

(I've had no success using FSMC_MemoryDataWidth=FSMC_MemoryDataWidth_8b to write to the ili9325,

even though you will only use either the upper 8 or lower 8 bits). Since your code sees HADDR

mapping, and the pins see FSMC A[24:0] as HADDR[25:1], you need to shift one more bit

(so 1<<17, not 1<<16). See pp. 1127, table 164 of the ref. manual (stm publication RM0090).

I ported a little graphics library and driver for the ili9325/28 from adafruit to work with

stm32f4 Discovery hardware using FSMC. You can check it out on github:

https://github.com/blaezec/stm32f4/tree/master/adafruitTFTLDCport

I commented a lot where I needed to figure things out, so maybe it's helpful.