Skip to content

Latest commit

 

History

History

1_Flash_library

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

Piu' sotto, al termine della lingua inglese trovi il testo in italiano. _
Below the English text you'll find the Italian version



1) Using the W25QXXXX Winbond SPI Flash chip library

Here you'll find documentation about handling a flash memory chip connected to a uC SPI port

  • (1) in CubeMX:
    creating your STM32 project assign an SPI port to the communication with the Flash memory.
    SPI must be set this way:

    Mode value
    mode Full-Duplex Master
    NSS Disable
    Parameter value
    Frame format Motorola
    Data size 8 bit
    First bit MSB first
    CPOL low
    CPHA 1 Edge
    CRC calculation disabled
    NSS type Output Sw

    SPI pins must have these names:

      FLASH_SCK
      FLASH_MISO
      FLASH_MOSI

    Setup a pin as GPIO_Output:
    pinname to assign output level mode pull-up/down
    FLASH_CS high Output push pull No pull-up/down

    Pin speed affects SPI port: rise (step by step from LOW to VERY HIGH) pins speed if you see uC cannot handle the defined communication speed (more information on your uC datasheet).


  • (2) in CubeIDE:
    after saving CubeMX and after C code generation:
      copy into the "include" folder (core\inc) z_flash_W25QXXX.h file
      copy into the "source" folder (core\src) z_flash_W25QXXX.c file

  • (3) in main.h:
    open file main.h and edit /* USER CODE BEGIN Includes */ segment, this way:
    (main.h)
    ...
    /* Private includes ----------------------------------------------------------*/
    /* USER CODE BEGIN Includes */
    #include "z_flash_W25QXXX.h"
    /* USER CODE END Includes */
    ...

  • (4) in z_flash_W25QXXX.h:
    edit file z_flash_W25QXXX.h this way:
    • into segment STEP1:
      register SPI used, updating the two lines (hspi1/SPI1, hspi2/SPI2, ...)
    • into segment STEP2:
      no changes: currently available only "Fast Mode"
    • into segment STEP3:
      no changes: currently available only "Polling Mode"
    • into segment STEP4:
      update all parameters with information about memory chip to handle.
      Currently file shows, inside comments, configuration parameters for:
        W25Q80DV/DL
        W25Q64JV
        W25Q128JV
      if you are using a chip of these, you just need to copy the related commented parameters to the uncommented area STEP4
      if you are using a different memory chip, just use this data as example of what is needed for a correct library setup.

Having done what above shown, you can use all functions of the library handling flash.
Each function has its own description and help, inside z_flash_W25QXXX.c file



Back to the home page



GitHub Folders

This guide is divided in 4 chapters following the above list.








Gestire un chip SPI Flash W25Q di Winbond con questa libreria

Qui trovi le informazioni su come gestire una memoria flash connessa alla porta SPI del uC

  • (1) in CubeMX:
    durante la creazione del progetto, assegnare una porta SPI per la comunicazione con la memoria Flash.
    la porta SPI deve essere configurata così:

    Mode value
    mode Full-Duplex Master
    NSS Disable
    Parameter value
    Frame format Motorola
    Data size 8 bit
    First bit MSB first
    CPOL low
    CPHA 1 Edge
    CRC calculation disabled
    NSS type Output Sw

    Ai pin della porta SPI assegnare i nomi:

      FLASH_SCK
      FLASH_MISO
      FLASH_MOSI

    Configura un altro pin come GPIO_Output:
    pinname to assign output level mode pull-up/down
    FLASH_CS high Output push pull No pull-up/down

    La velocità del pin ha effetti sulla velocità della porta SPI: aumenta (per gradi da LOW to VERY HIGH) la velocità dei pin se vedi che il uC non riesce a gestire la velocità di comunicazione assegnata (maggiori informazioni sul datasheet del tuo uC).


  • (2) in CubeIDE:
    dopo aver salvato la configurazione CubeMX e generato il codice C:
      copiare nella cartella "include" (core\inc) il file z_flash_W25QXXX.h
      copiare nella cartella "source" (core\src) il file z_flash_W25QXXX.c

  • (3) in main.h:
    aprire il file main.h e modifica il segmento /* USER CODE BEGIN Includes */ in questo modo:
    (main.h)
    ...
    /* Private includes ----------------------------------------------------------*/
    /* USER CODE BEGIN Includes */
    #include "z_flash_W25QXXX.h"
    /* USER CODE END Includes */
    ...

  • (4) in z_flash_W25QXXX.h:
    aprire il file z_flash_W25QXXX.h e modificare in questo modo:

    • nel segmento STEP1:
      indicare la porta SPI utilizzata aggiornando le due voci (hspi1/SPI1, hspi2/SPI2, ...)
    • nel segmento STEP2:
      non modificare: attualmente disponibile solo la modalità "Fast Mode"
    • nel segmento STEP3:
      non modificare: attualmente disponibile solo la modalità "Polling Mode"
    • nel segmento STEP4:
      aggiornare tutti i parametri con le informazioni del chip di memoria utilizzato.
      Attualmente il file contiene nei commenti le configurazioni relative a:
        W25Q80DV/DL
        W25Q64JV
        W25Q128JV
      se si utilizza uno di questi chip è sufficiente copiare i dati delle righe di configurazione commentate, nell'area di informazione STEP4
      se si usano altri chip, usare questi dati come esempio per la configurazione corretta.

Al termine e' possibile utilizzare le varie funzioni della libreria per gestire la memoria Flash
Le funzioni sono autodescritte e commentate nel file z_flash_W25QXXX.c



Torna alla home page