cancel
Showing results for 
Search instead for 
Did you mean: 

FSMC-why do I need it?

navintiwari08
Associate III
Posted on February 06, 2016 at 06:37

hello there,

I've seen on some forums that people are suggesting to use FSMC to interface LCDs. Many LCD drivers also make use of FSMC. So, I tried to find out what FSMC does. ST provides manual that explains all the interfacing info about FSMC. However, I want to know very basic of what FSMC does? Why do I need it? How is it different from normal access? If you could refer me to some link that explains how fsmc accesses external memory and role does the processor plays in all this? I'm using STM32F103ZET6. I want to use emWin drivers to interface SSD1289 LCD driver. But before that I want to have a basic understanding of how FSMC works. Thanks for your time!

#ssd1289 #ssd1289 #ssd1289 #stemwin #stemwin #stemwin #stm32f1 #stm32f1 #fsmc
11 REPLIES 11
pkumar1883
Associate II
Posted on February 06, 2016 at 07:26

Dear navin,

What is FSMC--

FSMC is an interface used to connect external memories(like NAND/NOR Flash etc).As you know these external memories are used where we need to process a large data at some high speed. So we need some means of hardware that can transfer data at high speed. Best solution for this is to use Parallel line protocol(hardware), and the name of that  is FSMC. So FSMC is a parallel line interface.

Why To Use with  LCD-

 

Generally you interact with your LCD using some driver(like  SSD1289 LCD driver). Generally these drivers provide 2 interfaces to interact with outside controller, serial interface and parallel interface. Obviously for best performance and fast spped we prefer parallel. So to interact though this parallel interface we connect LCD with our microcontroller using FSMC.

/*Please mark helpfull if this post helps you or solves your problem.*/

/**disclaimer**/

/* I am not a person from ST Technical Support Team. So please verify/test any support/suggestion at your end.*/

/* This post is only for general support purpose and free of any charge.If you need any personal support for your work please contact at 

embeddeddesign.help@gmail.com

*/

Radosław
Senior II
Posted on February 06, 2016 at 18:59

Becose use a FSMC to drive LCD with parraler interface is easier and have bigger performance. It is posibility to use a DMA.

this LCD have interface similar to SRAM, so you can map LCD into STM memory map, and FSMC will generate neccesary signals for them - read, write, en and so on.

navintiwari08
Associate III
Posted on February 07, 2016 at 15:22

hello KK,

thanks for the reply. But I'm little confused here. Let me be specific and talk about interfacing SSD1289 using FSMC. Now. ssd1289(lcd), requires 16 bit data width, which is easily configurable by FSMC as it provides 8/16 bit data bus. However, FSMC also provides 26 bits address bus. But in case of ssd1289, there is no such address bus present. Also, the ssd1289 datasheet does not mention any memory map(internal SRAM). So,

1. How can I write to specific memory address on LCD when I'm not going to use FSMC address bus?

2. the LCD needs setting of index register and then writing data. In some lcd libraries, this is accomplished by FSMC data bus only. could you shed some light on it if possible?

3. I've also seen in some libraries, defining LCD_BASE as  0x60000000. and data and registers are read and written using this. So, if I attempt to write to memory location 0x60000000, will it automatically refer to the LCD register?

I'm new to all this and would really appreciate if you could help. Thanks!

Radosław
Senior II
Posted on February 07, 2016 at 15:40

1. look for aplication note abaut this.

2. You need create address decoder for data, and control. LCD will have 2 addresses.

Search some schematics.

navintiwari08
Associate III
Posted on February 07, 2016 at 16:57

hello,

I looked for some datasheets and found this...

Typical use of the FSMC to interface with an LCD module

The STM32F10xxx FSMC has four different banks of 64 Mbytes to support NOR Flash

memories/PSRAMs and similar external memories.

The external memories share the addresses, data and control signals with the controller.

Each external device is accessed by means of a unique Chip Select signal, but the FSMC

can gain access to only one external device at a time. Each bank is configured by means of

dedicated registers including the different features and the timing parameters.

As we have seen above, the FSMC provides all the signals needed by the LCD controller.

The FSMC signals used for LCD interfacing are described below:

Å“ FSMC [D0:D15]: FSMC databus: 16-bit width

Å“ FSMC NEx: FSMC Chip Select

Å“ FSMC NOE: FSMC Output Enable

Å“ FSMC NWE: FSMC Write Enable

Å“ FSMC Ax: one address line used to select between LCD Registers and LCD Display

RAM where x can be 0 to 25

Note: The prefix gNh in signal names specifies that the signal is active low.

The LCD address depends on the used FSMC NOR Flash/PSRAM bank (NEx) and the

selected address (Ax) to drive the LCD RS pin.

Example: with NE2 and A4, the LCD base address will be 0x6400 0000 and 0x6400 0020;

with NE4 and A0, the LCD base address will be 0x6C00 0000 and 0x6C00 0002.

now, the doubt is that when I use NE4, the base address becomes 0x6C00 0000 as 4th sub bank is selected. But If I'm using A0 for driving RS of LCD, shouldn't the offset become 0x01, giving the address as 0x6C00 0001.? why does it say 0x6C00 0002 above in the datasheet? what am I missing?

Radosław
Senior II
Posted on February 07, 2016 at 17:40

16-bit data- you forgot about it, address will devided by 2.

navintiwari08
Associate III
Posted on February 07, 2016 at 17:51

hey Dembek,

Thanks for the help. You are right. I'm dealing with 16 bit data. Forgot about it. will interface LCD. let me see how it goes..

pkumar1883
Associate II
Posted on February 08, 2016 at 08:53

Dera navin,

FSMC provides you 2 direct memory locations, one for your register index and another for your register data. Address in STM32 are as follows- index=((uint32_t)0x60000000) data=((uint32_t)0x60020000). So to send some value to LCD register you only write your index and data values at the above mentioned addresses. As shown in the below sample code--


#define LCD_Register_Index_ptr ((uint32_t)0x60000000)

#define LCD_Register_Data_ptr ((uint32_t)0x60020000)


void
main()

{

LCD_Write_Cmd(0x0023, 0x4005);
//0x0023 register index, 0x4005 register data

}

void
LCD_Write_Cmd(unsigned 
int
index, unsigned 
int
val)

{

*(__IO uint16_t *) (LCD_Register_Index_ptr )= index; 

*(__IO uint16_t *) (LCD_Register_Data_ptr )= val;

}

/*Please

mark helpfull

if this post helps you or solves your problem.*/

/**disclaimer**/

/* I am not a person from ST Technical Support Team. So please verify/test any support/suggestion at your end.*/

/* This post is only for general support purpose and free of any charge.If you need any personal support for your work please contact at

embeddeddesign.help@gmail.com

*/

RaceNJason
Associate

Before you read my post please note that this is for a 16bit parallel FSMC setup. If you are using an 8bit setup it could differ or at least differ in the RAM read...I have only used FSMC in 16bit so modify the below as needed.

Although the other posts were posted some 7 years ago, I can't help but add some information because of how much time I spent regarding FSMC and the information that is on the internet. The number one problem I keep running across in regards to FSMC is the address pointers used and why is it that either no one explains that their setup could differ and why.  In particular the part about 

#define LCD_Register_Index_ptr ((uint32_t)0x60000000)
#define LCD_Register_Data_ptr ((uint32_t)0x60020000)

There is sooo much more involved than this value and how it is derived. First part...FSMC has 4 banks of addresses as follows:

0xA0000000 - 0xA0000FFF FSMC control register
0x90000000 - 0x9FFFFFFF FSMC bank 4
0x80000000 - 0x8FFFFFFF FSMC bank 3
0x70000000 - 0x7FFFFFFF FSMC bank 2
0x60000000 - 0x6FFFFFFF FSMC bank 1

Although STM shows the above as bank N, this does NOT refer to the bank being used by the device. For RAM and LCD type displays, the start address is bank 1. Of course this causes everyone to show the command address as the 0x60000000 address which is the start of the problem. Here is the additional breakdown of bank 1.

0x6C000000 -0x6FFFFFFF FMC NOR/PSRAM/SRAM 4 Bank1 (or remap of FMC SDRAM Bank1)
0x68000000 -0x6BFFFFFF FMC NOR/PSRAM/SRAM 3 Bank1 (or remap of FMC SDRAM Bank1)
0x64000000 -0x67FFFFFF FMC NOR/PSRAM/SRAM 2 Bank1 (or remap of FMC SDRAM Bank1)
0x60000000 -0x63FFFFFF FMC NOR/PSRAM/SRAM 1 Bank1 (or remap of FMC SDRAM Bank1)

The 'actual' bank will depend on the the NE[Bank] pin used. This means if you use NE3 pin, it will map to bank 3. Which of course then means, only if you use NE1 pin will the 0x60000000 address be correct. Otherwise it will do you no good and you will wonder why nothing is working.

// So I use pin NE4 which is bank 4 therefore
#define FSMC_BANK4_ADDRESS 0x6C000000

// Create this structure
typedef struct
{
__IO uint16_t LCD_REG;
__IO uint16_t LCD_RAM;
} LCD_TypeDef;

Now go to your FSMC configuration, find your LCD section and look at the 'LCD Register Select' pin. In my case it is A6 (for others it is A18). Take this number and do the following formula
#define TFT_PIN_ADDRESS (1 << (6 + 1)) // This would be for the A6 pin and it should equal 0x80
#define TFT_PIN_ADDRESS (1 << (18 + 1) // This would be for the A18 pin and it should equal 0x80000

// Now define this noting that we subtract 2 from the TFT_PIN_ADDRESS - this offsets the address by the command address as you'll see
#define TFT_BASE_ADDRESS ((uint32_t*)(FSMC_BANK4_ADDRESS | (TFT_PIN_ADDRESS - 2))) // Bank 4 Cmd

// And now
#define LCD_FSMC_ADDRESS ((LCD_TypeDef *)TFT_BASE_ADDRESS)

Now all you have to do is write to
LCD_FSMC_ADDRESS->LCD_REG = nCmd
LCD_FSMC_ADDRESS->LCD_RAM = nData

As you can see from the above, there are way more steps to getting the correct address and why just copy/pasting all this code on the internet is causing so many people so many problems. It is because they are assuming the addresses being used (without any notations on them) are the correct ones when most of the time they are not.