STM32F1_FSMC reads and writes external SRAM

Publisher:梦幻之光Latest update time:2017-09-15 Source: eefocusKeywords:STM32F1 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Preface

Today we will summarize "STM32F103 FSMC read and write external SRAM", mainly using FSMC to control external SRAM and perform read and write operations on SRAM. The project provided in this article performs read and write operations on SRAM similar to read and write operations on FLASH.

The content about STM32's FSMC (Flexible Static Memory Controller) is quite practical and also quite important in practical applications (for those who need to use FSMC). Using FSMC to control external devices is much more efficient than using software simulation to control, and the operation is simpler.

Maybe beginners don't know about FSMC or are not interested in it. Because FSMC is mainly used to expand RAM and ROM in actual development, beginners don't have high demand for RAM and ROM, and basically the internal resources are enough. People who like to use LCD screens should know about FSMC, because FSMC is also a good way to control LCD. Many LCD screens on development boards on the market are compatible with FSMC.

https://yunpan.cn/cSrN5SYtDcyBA   Access password: 47fb

 

The information of STM32F10x can be downloaded from my 360 cloud disk:

https://yunpan.cn/crBUdUGdYKam2Access    password ca90

 

Content explanation

Project Summary: The project provided is to read and write external SRAM, which can be used as a cache (such as a BUF), but it is not the RAM (running memory) of the chip, it only performs read and write operations on SRAM.

Program operation flow: Power on and write external SRAM data "0 - 262143" (just 1M space, 4 bytes of space per data), then read the data through the read function and print it out through the serial port. Here, the serial port prints data once each time it is read, and the LED changes once. (Please observe the phenomenon)

 

The projects provided are based on the principle of simplicity, with detailed Chinese annotations to facilitate yourself and everyone.

 

Regarding "STM32F103 on-chip FLASH programming", I will describe the important points below:

1. Clock


This function is located under the bsp.c file;

Turn on the FSMC and the clock pins you need to use.

 

2. FSMC pin configuration


This function is located under the fsmc.c file;

All pins using FSMC must be configured as "GPIO_Mode_AF_PP", otherwise they cannot be used (those interested can try it). For NE3, it is: NOR/PSRAM3. The project I tested uses NOR/PSRAM3 of FSCM storage block 1 (see the figure below). So the address in my test project is "0x68000000". In fact, this address is very particular. Please see the last point.

 

 

3. FSMC configuration


This function is located under the fsmc.c file;

The configuration here is somewhat related to your SRAM (speed, data width, etc.).

 

3. External SRAM write data



This function is located under the fsmc.c file;

Write data to 1M SRAM (for testing) to facilitate the following read operation.

 

4. External SRAM read data

 


This function is located under the fsmc.c file;

Read data from 1M SRAM and print the written data through the serial port. There is a delay between each reading and printing, so the whole reading process takes a long time.

This address can be modified, or a section can be selected for reading and testing. I hope that everyone who sees this will modify the program and test it themselves to facilitate memory and consolidation.

 

5. Today’s Focus

A. Regarding the address, the external SRAM address of the project provided today is "0x68000000" (macro definition in fsmc.h). People who are good at finding problems and doing things will find a problem. I changed this address to "0x68100000" or "0x68200000" and the test results are the same. I will tell you the answer. The effect is indeed the same. The reason is that the external SRAM capacity "SRAM_EXT_SIZE" is 1M, and "0x00100000" is exactly 1M. The address overflow part here just offsets it, so why the address is changed. The effect is the same. But the address must be in the NOR/PSRAM3 area of ​​storage block 1.

B. Today I configured the FSMC by myself through the standard library. In fact, there is a source code in the "system_stm32f10x.c" file that uses registers to directly configure the FSMC. Interested friends can take a look. Today, I use the standard library configuration to actually hope that everyone can understand the functions of each parameter. In fact, I hope that everyone will still use the configuration in "system_stm32f10x.c" after becoming familiar with the configuration. After all, it is officially provided, and its configuration efficiency is relatively high.

 

illustrate

The software project provided today is based on the STM32F103 large-capacity chip. Medium- and small-capacity chips do not have the FSMC function and naturally cannot be used. In fact, as long as some configurations of the project are appropriately modified, all STM32F1 chips with FSCM function are applicable.


Keywords:STM32F1 Reference address:STM32F1_FSMC reads and writes external SRAM

Previous article:STM32F1_On-chip FLASH programming
Next article:STM32F1_External SRAM as running memory

Recommended ReadingLatest update time:2024-11-15 13:39

STM32 FSMC
In-depth study of STM32 FSMC bus   Due to the need for CPU and FPGA communication and the familiarity with the 8080 bus, the FSMC bus of STM32 was used as the inter-chip communication interface. FSMC can reach a write speed of 16MHz, and theoretically can write 1024*768 pictures at 20fps. (Of course, it is actuall
[Microcontroller]
STM32 FSMC
UCOS2_STM32F1 transplantation detailed process (Part 3)
I. Overview The previous article talked about the configuration related to ST chips and OS tailoring. Following the previous article, I will talk about the porting of UCOS. This article mainly talks about the underlying port codes of os_cpu_a.asm, os_cpu_c.c and os_cpu.h files under uC/OS-II Ports . Please download
[Microcontroller]
UCOS2_STM32F1 transplantation detailed process (Part 3)
【STM32】Some understanding of FSMC
(1) Address in FSMC: I have read many tutorials online, and they are almost identical. I am confused. Regarding the address line, many people wrote: "For example, to set FSMC_A16 high, just operate on the address: 60000000 + 2^16*2". I have been struggling with the question of why "*2" is needed. I have been thinking
[Microcontroller]
【STM32】Some understanding of FSMC
STM32FSMC mechanism FlaSh memory expansion
  STM32 is a 32-bit microcontroller series based on the ARM core Cortex-M3 launched by ST (STMicroelectronics). The Cortex-M3 core is specially designed for low-power and price-sensitive applications, with outstanding energy efficiency and processing speed. By adopting the Thumb-2 high-density instruction set, the Cor
[Microcontroller]
STM32FSMC mechanism FlaSh memory expansion
Solution to the problem that peripherals are not displayed during Stm32f1 Keil5 debugging
When debugging Stm32f103 Keil5, there is nothing in peripherals, it is blank: When debugging, I found that the peripherals are like this: blank Solution Change the debug view to the following   This will have this effect
[Microcontroller]
Solution to the problem that peripherals are not displayed during Stm32f1 Keil5 debugging
stm32_FSMC Notes
The FSMC bus has been briefly introduced before, so I will not repeat it here. I will just briefly talk about a few issues that need to be paid attention to during its configuration process: 1. FSMC internal structure and mapped address space FSMC contains four main modules: AHB interface, NOR Flash and PSRAM controll
[Microcontroller]
Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号