Setting GPIO as High Impedance

hgptamn
Posts: 26
Joined: Mon Oct 16, 2017 4:47 pm

Setting GPIO as High Impedance

Postby hgptamn » Thu Feb 22, 2018 2:31 pm

Hi!
Is there a way to set a GPIO pin as a high impedance pin?

I'm trying to program an ESP32 (board 1) external flash, using another ESP32 (board 2) conected via SPI.
I can access board 1 external flash using board 2, but once I do that board 1 is not able to boot anymore, as the SPI lines seem to not switch to a high impedance state on board 2 (the programmer). To put it in another way: board 2 (the programmer) latches on board 1 flash SPI lines, not releasing them.

What I've tried:

Code: Select all

void loop(void)
{

  Serial.println("Disabling Board 2 CPU");
  delay(4500);
  digitalWrite(CPU, LOW);
  Serial.println("Board 2 CPU disabled!");
  delay(4000);

  //select proper pinMode for SPI flash access
  pinMode(CSPIN, OUTPUT);
  pinMode(MISO, INPUT);
  pinMode(MOSI, OUTPUT);
  pinMode(SCK, OUTPUT);

  Serial.println("Reading flash ID");

  Serial.print("ID bytes: ");
  uint16_t id[3];
  digitalWrite(CSPIN, LOW);
  SPI.transfer(0x9F);
  id[0] = SPI.transfer(0);
  id[1] = SPI.transfer(0);
  id[2] = SPI.transfer(0);
  digitalWrite(CSPIN, HIGH);
  SPI.endTransaction();
  Serial.print(id[0], HEX); Serial.print(" "); Serial.print(id[1], HEX);  Serial.print(" ");  Serial.println(id[2], HEX);
  delay(2000);

  //put SPI lines back in HIGH IMPEDANCE state in order for board 1 to boot from flash 
  Serial.println("put Chip Select pin in high impedance");
  pinMode(CSPIN, INPUT);
  digitalWrite(CSPIN, LOW);
  delay(3000);
  Serial.println("put MISO in high impedance");
  pinMode(MISO, INPUT);
  digitalWrite(MISO, LOW);
  delay(3000);
  Serial.println("put MOSI in high impedance");
  pinMode(MOSI, INPUT);
  digitalWrite(MOSI, LOW);
  delay(3000);
  Serial.println("put SCK in high impedance");
  pinMode(SCK, INPUT);
  digitalWrite(SCK, LOW);

  Serial.println("Wake up CPU on board 1");
  digitalWrite(CPU, HIGH);
  delay(6000);

}


At the end of this sequence board 2 doesn't boot anymore.

Who is online

Users browsing this forum: No registered users and 3 guests