Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug report - *SPI Flash W25Q128 not working using SPI2 on STM32F103C8T6 (Blue Pill) or STM32F401CCU (Black Pill)* #209

Open
delgadosouza opened this issue May 28, 2020 · 0 comments
Assignees
Labels
possible bug Possibly a bug. Needs verification before moving to *bug* status.

Comments

@delgadosouza
Copy link

Describe the bug
When using the SPI Flash W25Q128 on the second SPI port of both the variants BluePill and BlackPill the code compiles but the chip is not recognized.

To Reproduce
I used the Arduino_Core_STM32 by stm32duino.
To make sure the frequency wasn't too high I changed the "defines.h" file of the library SPIMemory. I edited the frequency for non ESP32 boards:

#if defined (ARDUINO_ARCH_ESP32)
#define SPI_CLK       20000000        //Hz equivalent of 20MHz
#else
#define SPI_CLK       1000000       //Was 104000000
#endif

Also I had to define the ARCH_STM32 flag that was used by the library but not set by the core.

#define ARCH_STM32 true // The library didn't recognize the archtecture by itself
#include<SPIMemory.h> // SPIMemory library v 3.2.0 by Marzogh

// SPI2
#define SPI2_MISO PB14
#define SPI2_MOSI PB15
#define SPI2_SCK PB13
#define SPI2_CS PB12

// SPI 1
#define SPI1_SCK PA5
#define SPI1_MOSI PA7
#define SPI1_MISO PA6
#define SPI1_CS PA4

// THE LINES BELOW WORK (wired to SPI1 instead of SPI2, of course)
//SPIClass my_SPI1(SPI1_MOSI,SPI1_MISO,SPI1_SCK,SPI1_CS);
//SPIFlash flash(SPI1_CS, &my_SPI1);

SPIClass my_SPI2(SPI2_MOSI,SPI2_MISO,SPI2_SCK,SPI2_CS);
SPIFlash flash(SPI2_CS, &my_SPI2);

void setup() {
  Serial.begin(115200);
  while (!Serial) ; // Wait for Serial monitor to open
  delay(50);
  
  flash.begin();
  delay(50);

  // Get ID
  uint32_t JEDEC = flash.getJEDECID();
  if (!JEDEC) {
    Serial.println("Check wiring.");
  } else {
    // Show ID
    Serial.print("JEDEC ID: 0x"); Serial.println(JEDEC, HEX);
    Serial.print("Man ID: 0x"); Serial.println(uint8_t(JEDEC >> 16), HEX);
    Serial.print("Memory ID: 0x"); Serial.println(uint8_t(JEDEC >> 8), HEX);
    Serial.print("Capacity: "); Serial.println(flash.getCapacity());
    Serial.print("Max Pages: "); Serial.println(flash.getMaxPage());
  }
}

void loop() {}

Answer on SPI 1:
image

Answer on SPI 2:
image

For some reason it didn't even print the "Check wiring." message...

Desktop (please complete the following information):

  • OS: Windows 10 Pro Version 1909
  • Arduino IDE version: Tested with Arduino IDE 1.8.13 Hourly Build and also Arduino IDE 1.9.0-beta.
  • STM32 core version: STM32 Cores 1.9.0
  • Tools menu settings if not the default:
    For Blue Pill:
    image

For Black Pill:
image

Tried same cofigs on both Arduino IDE versions.

  • Upload method: STLink for the BluePill and USB (DFU) for BlackPill

Board (please complete the following information):

  • Name: Blue Pill STM32F103C8T6 and Black Pill STM32F401CCU
  • Hardware Revision: WeAct v2.0 (Black Pill), Generic BluePill
  • Extra hardware used if any: SPI Flash W25Q128
    bluepill
    blackpill

Additional context
I would like to use both the LCD ST7920 and the SPI Flash W25Q128, each one in a separate SPI. I have heard that the ST7920 controller doesn't play nicely with other devices on the same bus.

I reached out to the Arduino_Core_STM32 people and they said that their implementation of the SPI2 works fine on both boards.

Any help would be really apreciated! Thank you!

@delgadosouza delgadosouza added the possible bug Possibly a bug. Needs verification before moving to *bug* status. label May 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
possible bug Possibly a bug. Needs verification before moving to *bug* status.
Projects
None yet
Development

No branches or pull requests

2 participants