2016-02-05 09:37 PM
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 #fsmc2016-02-05 10:26 PM
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
*/2016-02-06 09:59 AM
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.2016-02-07 06:22 AM
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!2016-02-07 06:40 AM
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.2016-02-07 07:57 AM
2016-02-07 08:40 AM
16-bit data- you forgot about it, address will devided by 2.
2016-02-07 08:51 AM
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..2016-02-07 11:53 PM
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
*/
2023-08-26 03:18 PM
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.