2

I am trying to understand the Flexible Static Memory Controller (FSMC) on the STM32f4-discovery.

I have done a lot of research and I cannot understand how this works. I am a completely self taught programmer who is currently pursuing a degree in chemistry, so be easy on me lol.

I have found these websites which I have been using to figure this out:

https://electronics.stackexchange.com/questions/165200/stm32f407-fsmc-interface-with-tft-lcd

http://prog3.com/sbdm/blog/u013030441/article/details/48159101

http://www2.st.com/content/ccc/resource/technical/document/application_note/85/ad/ef/0f/a3/a6/49/9a/CD00201397.pdf/files/CD00201397.pdf/jcr:content/translations/en.CD00201397.pdf

I have also found libraries with example code from ST themselves.

OK, now the misunderstanding:

When I look at the above code for both the TFT drivers, I see that the LCD is accessed with structs or definitions like

#define LCD_REG      (*((volatile unsigned short *) 0x60000000)) 
#define LCD_RAM      (*((volatile unsigned short *) 0x60020000)) 
LCD_RAM = data;
LCD_REG = command;

My question is why they have to access two areas of the FSMC SRAM bank instead of one. Basically why can't I just send data to the LCD by writing only to LCD_REG (the start of the memory bank)?

There must be something about FSMC that I am missing. I have read the datasheet multiple times and I know the bank starts at 0x6000 0000 but I can't reason why they would access the bank in another section at 0x6002 0000.

Any help in understanding is greatly appreciated. If you know of a book or website I can use to learn FSMC I would be very grateful.

Thank you for everyones time!

kalmiya
  • 2,988
  • 30
  • 38
Bradley bare
  • 21
  • 1
  • 4

2 Answers2

3

Look at Fig.7 in the Application Note you've linked. They've connected 16 data lines, but only a single address line goes to the RS pin. Then, the LCD controller becomes a memory mapped peripheral with two registers. If that particular bit in the address is 0, then the command register is addressed, if it's 1, then the data register. The rest of the address lines are not connected, so their state is irrelevant, one could e.g. access the data register at 0x60FFFFFF as well. Note that all three examples are using different address lines, therefore a different address for the data register.

To use the LCD, you write a command code to the command register, optionally followed by some parameters in the data register, then the next command, and so on. There are commands to set up the displayed area, color mapping, brightness, some special effects like scrolling, etc. Each command takes a fixed number of parameters, except there is one called something like Write RAM, where the parameters are the actual pixel data. Pixel data is stored sequentially in the display memory, you can set any number of them with the Write RAM command, you can as well stay forever in this mode, and send display updates one after another.

  • I think I understand now. I also found this link which kinda helped. https://github.com/hampussandberg/HexConnect/wiki/LCD-ER_TFTM070_5 But I don't know why I can't find that figure in the reference manual or datasheet. I am working on the code for the LCD now so I'll let everyone know how it worked. Thanks for the help! – Bradley bare Apr 23 '16 at 01:36
0

Seems like the answer in 2016 is a little over complicated for the asked question. FSMC controls the writing to command or to data via the RS pin as well as the actual data pins. In order to tell FSMC you are going to write a command, it simply provides a specific REG (CMD) address. So when FSMC sees you are writing to this address, in the background it switches the pin for you to command. If you write to the DATA address, FSMC switches the pin for you to data/ram. When FSMC is controlling the pins, trying to write to them directly gets ignored. So you can't, for example, switch the CMD/DATA pin manually. And FSMC doesn't have a function to call to do that (especially when it is not needed). Of course if it did, it wouldn't be as fast as just writing to a special register address which then knows how to switch everything in the background for you. And that is why FSMC has two addresses for accessing these devices and why you can't just write to one address.

Jason
  • 1
  • 1