SPI_FLASH

所属分类:单片机开发
开发工具:C/C++
文件大小:19KB
下载次数:18
上传日期:2013-10-14 19:14:02
上 传 者stefan2005
说明:  stm32f4 series, SPI with Flash.
(C code for stm32f4 series, SPI with Flash.)

文件列表:
SPI_FLASH\main.c (6184, 2013-01-18)
SPI_FLASH\spi_flash.c (19645, 2013-01-18)
SPI_FLASH\spi_flash.h (5123, 2013-01-18)
SPI_FLASH\stm32f4xx_conf.h (3749, 2013-01-18)
SPI_FLASH\stm32f4xx_it.c (4584, 2013-01-18)
SPI_FLASH\stm32f4xx_it.h (2199, 2013-01-18)
SPI_FLASH\system_stm32f4xx.c (21857, 2013-01-18)
SPI_FLASH (0, 2013-09-04)

/** @page SPI_FLASH SPI FLASH example @verbatim ******************** (C) COPYRIGHT 2013 STMicroelectronics ******************* * @file SPI/SPI_FLASH/readme.txt * @author MCD Application Team * @version V1.1.0 * @date 18-January-2013 * @brief Description of the SPI FLASH example. ****************************************************************************** * * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); * You may not use this file except in compliance with the License. * You may obtain a copy of the License at: * * http://www.st.com/software_license_agreement_liberty_v2 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ****************************************************************************** @endverbatim @par Example Description This example provides a basic example of how to use the SPI firmware library and an associated driver "spi_flash.c" to communicate with an M25P*** SPI FLASH. The first step consist in reading the SPI Flash ID. A comparison between the ID read from SPI flash and the expected one is done and LED1 is turned on in case of success otherwise LED2 is turned on. Using this driver the program performs an erase of the sector to be accessed, a write of a Tx_Buffer, defined in the main.c file, to the memory followed by a read of the written data. Then data read from the memory stored in the Rx_Buffer are compared with the expected values of the Tx_Buffer. The result of this comparison is stored in the "TransferStatus1" variable. A second erase of the same sector is done at the end, and a test is done to be sure that all the data written there are erased further to the sector erase. All the data location are read and checked with 0xFF value. The result of this test is stored in "TransferStatus2" variable which is FAILED in case of error. The FLASH_WRITE_ADDRESS and the FLASH_READ_ADDRESS where the program start the write and the read operations are defined in the main.c file. @par Directory contents - SPI/SPI_FLASH/spi_flash.c SPI M25Pxxx driver - SPI/SPI_FLASH/spi_flash.h Header for spi_flash.c - SPI/SPI_FLASH/stm32f4xx_conf.h Library Configuration file - SPI/SPI_FLASH/stm32f4xx_it.c Interrupt handlers - SPI/SPI_FLASH/stm32f4xx_it.h Header for stm32f4xx_it.c - SPI/SPI_FLASH/main.c Main program - SPI/SPI_FLASH/system_stm32f4xx.c STM32F4xx system source file @note The "system_stm32f4xx.c" is generated by an automatic clock configuration tool and can be easily customized to your own configuration. To select different clock setup, use the "STM32F4xx_Clock_Configuration_V1.1.0.xls" provided with the AN3***8 package available on ST Microcontrollers @par Hardware and Software environment - This example runs on STM32F4xx. - This example can't be tested with STM324xG-EVAL/STM32437I-EVAL evaluation board (no SPI FLASH available). - HW platform Set-up - Connect LED1 and LED2 respectively to PG.06 and PG.08 pins - Connect both SPI2 and SPI FLASH pins as following: - Connect SPI2_NSS (PI0) pin to SPI Flash chip select (pin1) - Connect SPI2_SCK (PI1) pin to SPI Flash serial clock (pin6) - Connect SPI2_MISO(PI2) pin to SPI Flash serial data output (pin2) - Connect SPI2_MOSI(PI3) pin to SPI Flash serial data input (pin5) - Connect SPI Flash Write Protect (pin3) to Vdd - Connect SPI Flash Hold (pin7) to Vdd - Connect SPI Flash Vcc (pin8) to Vdd - Connect SPI Flash Vss (pin4) to Vss @par How to use it ? In order to make the program work, you must do the following : - Copy all source files from this example folder to the template folder under Project\STM32F4xx_StdPeriph_Templates - Open your preferred toolchain - Add the file "spi_flash.c" to the project source list - Rebuild all files and load your image into target memory - Run the example *

© COPYRIGHT STMicroelectronics

*/

近期下载者

相关文件


收藏者