Skip to content

Wi-Fi won't start after long SPI transfer #3984

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

Open
azevedo-manuel opened this issue Dec 17, 2017 · 0 comments
Open

Wi-Fi won't start after long SPI transfer #3984

azevedo-manuel opened this issue Dec 17, 2017 · 0 comments

Comments

@azevedo-manuel
Copy link

Basic Infos

Hardware

Hardware: Wemos D1 mini Pro
Core Version: 2.3.0

Description

If sending a long SPI sequence before initializing Wi-Fi, Wi-Fi won't connect anymore. Example bellow fails at 29 times sending data over SPI, but works up to 28 times.
If starting Wi-Fi first, the problem seems to disappear.

Settings in IDE

Module: WeMos D1 R2 & mini
Flash Size: 4MB
CPU Frequency: 80Mhz
Upload Using: SERIAL
Reset Method: nodemcu

Sketch

#include <SPI.h>
#include <ESP8266WiFi.h>

char ssid[] = "myssid";
char pass[] = "mypassword"; 

void setup() {
  Serial.begin(115200);

  Serial.print("setup: Connecting to ");
  Serial.println(ssid);

  startupLogo(); // this makes the SPI calls
  
  WiFi.begin(ssid, pass);

  Serial.print("setup: ");
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println();
  
  Serial.println("setup: WiFi connected");
}

void loop() {

  SPIwrite(D0,0x53122);
  Serial.print("Loop!");
  delay(500);
  
}

void SPIwrite(byte nCS, unsigned long theString) { 
  Serial.printf("SPIwrite: SPI value = 0x%08x ",theString);
  Serial.println(theString,BIN);
  
  SPI.begin();
  SPI.beginTransaction(SPISettings(15000000, MSBFIRST, SPI_MODE0));
  digitalWrite(nCS, LOW); // device select
  SPI.transfer(theString); // 8 bits out
  digitalWrite(nCS, HIGH); // data  transfer to SPI outputs...
  SPI.endTransaction();
  SPI.end();
}

void startupLogo(){
  int i=0;

  while (i<29) {
    SPIwrite(D3, 0x22122);
    i++;
    delay(100);
  }

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant