⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readme.txt

📁 STM32 cortex m-3 的 spi驱动程序! 可以直接使用!
💻 TXT
字号:
/******************** (C) COPYRIGHT 2007 STMicroelectronics ********************
* File Name          : readme.txt
* Author             : MCD Application Team
* Version            : V1.0
* Date               : 10/08/2007
* Description        : Description of the SPI Example5.
********************************************************************************
* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
* CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/
本例展示了如何使用SPI固件函数库和相关的SPI Flash驱动来实现与M25P64 FLASH的通信。

第一步是读取SPI Flash ID,并把它和预设的ID进行核对,如果匹配则置PC.06为1,否则置PC.07为高。

然后,利用驱动程序对目标区域进行擦除,把“main.c”中定义的缓存Tx_Buffer写入,然后再读出,读出的数据存入缓存Rx_Buffer。比较两块缓存判断整个操作正确与否,判断结果放在变量“TransferStatus1”。

之后,对目标区域再进行擦除,检查之前写入数据的区域,判断擦除是否彻底。然后读出所有数据,检查是否为0xFF,0xFF表示这一位数据是经过擦除的。检查结果放在变量“TransferStatus2”中。

设置SPI1为主,8bit字长。设置管脚SPI1_NSS为push-pull输出,用来驱动SPI FLASH片选管脚。

文件“main.c”中定义的FLASH_WriteAddress和FLASH_ReadAddress表示程序开始写和读操作的地址。

设置系统时钟为72 MHz,SPI1波特率为18 Mbit/s。

由于缺少相应的硬件,本例未做针对STM3210B-LK1的修改和测试。

Example description
===================
This example provides a basic example of how to use the SPI firmware library
and an associate SPI FLASH driver to communicate with an M25P64 FLASH.
The first step consist on reading the SPI Flash ID. A comparison between the ID 
read from SPI flash and the expected one is done and the pin PC.06 is set in case
of success otherwise pin PC.07 is set.  
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 sector erase is done at the end, and a check of the Tx_Buffer data write 
location on SPI flash is made 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 whcih indicates its erase. The result of this test is stored in "TransferStatus2"
variable which is FAILED in case of error.
The SPI1 is configured as Master with an 8bits data size. The SPI1_NSS pin is used
as output push-pull to drive the SPI Flash chip select pin.  
The FLASH_WriteAddress and the FLASH_ReadAddress where the program start the write 
and the read operations are defined in the main.c file. 
The system clock is set to 72MHz and SPI1 baudrate to 18 Mbit/s.


Directory contents
==================
stm32f10x_conf.h   Library Configuration file
stm32f10x_it.c     Interrupt handlers
stm32f10x_it.h     Header for stm32f10x_it.c
main.c             Main program
spi_flash.c        SPI FLASH driver
spi_flash.h        Header for the spi_flash.c file


Hardware environment
====================
 - Connect both SPI1 and SPI FLASH pins as following:
    - Connect SPI1_NSS (PA.04) pin to SPI Flash chip select (pin1).
    - Connect SPI1_SCLK (PA.05) pin to SPI Flash serial clock (pin6).
    - Connect SPI1_MISO (PA.06) pin to SPI Flash serial data output (pin2).
    - Connect SPI1_MOSI (PA.07) 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
Note: This SPI Flash is already available on the STM3210B-EVAL board (and there 
      is no need for extra hardware connection).
 - Connect two leds to pins PC.06 and PC.07 (respectively LD1 and LD2 on
   STM3210B-EVAL board). 


How to use it
=============
In order to make the program work, you must do the following :
- Create a project and setup all your toolchain's start-up files
- Compile the directory content files and required Library files :
  + stm32f10x_lib.c
  + stm32f10x_spi.c
  + stm32f10x_rcc.c
  + stm32f10x_gpio.c
  + stm32f10x_nvic.c
  + stm32f10x_flash.c
    
- Link all compiled files and load your image into either RAM or FLASH
- Run the example


******************* (C) COPYRIGHT 2007 STMicroelectronics *****END OF FILE******

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -