0

huzzah32 io12 / SPI question
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

huzzah32 io12 / SPI question

by ubiubu on Thu Jan 10, 2019 5:45 pm

hi

a question about the huzzah32, if anyone had any insights:

the FAQ says: "IO12 - this pin has an internal pulldown, and is used for booting up. We recommend not using it or if you do use it, as an output only so that nothing interferes with the pulldown when the board resets"

what's confusing me is that (if i see it right) IO12 is routinely advertised as the ESP32 "native" MISO signal ("HSPI" port), so is it save to use IO12 for SPI purposes, or not?

thanks!

ubiubu
 
Posts: 8
Joined: Thu Jun 21, 2012 6:56 am

Re: huzzah32 io12 / SPI question

by adafruit_support_mike on Sat Jan 12, 2019 2:04 am

The ESP32 has two ways of routing peripheral signals to the physical pins.

The first one, the GPIO Matrix, can map any signal to any physical pin. There are about 240 possible IO signals, including four separate SPI peripherals.

The second one, the IO_MUX, bypasses the GPIO Matrix and makes connections between specific peripherals and specific pins. Those connections are faster than the GPIO Matrix, and are used by things like the SD card interface and the high-speed SPI peripheral.

GPIO12 is the IO_MUX connection for the HSPI peripheral's MISO signal. You could call it a 'native' connection, but it's more like a special case. The pin defaults to input with a pulldown when the ESP32 reboots, and the ESP32 checks the state of that pin during the boot process to decide how it should operate.

You can use the pin for SPI, but you have to be aware of the pulldown resistor and boot-time signal requirements. It's your job to make sure there are no conflicts that will cause problems.

adafruit_support_mike
 
Posts: 58483
Joined: Thu Feb 11, 2010 2:51 pm

Re: huzzah32 io12 / SPI question

by radhey04ec on Sat Aug 03, 2019 12:55 am

adafruit_support_mike wrote:The ESP32 has two ways of routing peripheral signals to the physical pins.

The first one, the GPIO Matrix, can map any signal to any physical pin. There are about 240 possible IO signals, including four separate SPI peripherals.

The second one, the IO_MUX, bypasses the GPIO Matrix and makes connections between specific peripherals and specific pins. Those connections are faster than the GPIO Matrix, and are used by things like the SD card interface and the high-speed SPI peripheral.

GPIO12 is the IO_MUX connection for the HSPI peripheral's MISO signal. You could call it a 'native' connection, but it's more like a special case. The pin defaults to input with a pulldown when the ESP32 reboots, and the ESP32 checks the state of that pin during the boot process to decide how it should operate.

You can use the pin for SPI, but you have to be aware of the pulldown resistor and boot-time signal requirements. It's your job to make sure there are no conflicts that will cause problems.





adafruit_support_carter wrote:For (2) - yes, see here:
https://learn.adafruit.com/adafruit-huz ... er/pinouts
Also see pin labels on bottom of board:
https://cdn-learn.adafruit.com/assets/a ... 1494445728



I am using FEATHER 32 Board for developing my project Energy meter. I am using SPI interface for communicating with IC.
I have checked following code with Arduino Uno, with Arduino IDE and it works properly.

I have also checked same code with ESP8266 NODEMCU with some changes and it works.

But I want to access live data using Bluetooth, that's why I have used ESP32 Feather board.

But since last 7 days I cant communicate successfully using SPI.

here is my code:

#include <SPI.h>
#define REG_RUN 0x0480
#define ADE9153A_RUN_ON 0x0001
static const int spiClk = 1000000; // 1 MHz
#define REG_VERSION_PRODUCT 0x0242
#define SPI_SCK 5
//uninitalised pointers to SPI objects
#define CS_PIN 2 //8-->Arduino Zero. 15-->ESP8266 Atuall is 16
#define ADE9153A_RESET_PIN 15 //On-board Reset Pin (4)
unsigned int data16;

void setup() {
//initialise two instances of the SPIClass attached to VSPI and HSPI respectively
Serial.begin(115200);
pinMode(ADE9153A_RESET_PIN, OUTPUT);
digitalWrite(ADE9153A_RESET_PIN, HIGH);
digitalWrite(ADE9153A_RESET_PIN, LOW);
delay(100);
digitalWrite(ADE9153A_RESET_PIN, HIGH);
delay(1000);
Serial.println("Reset Done");
//clock miso mosi ss
pinMode(CS_PIN, OUTPUT); // Added this line externally for ESP8266
digitalWrite(CS_PIN, HIGH);
delay(100);
digitalWrite(CS_PIN,LOW);
SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE0)); //set parameters
SPI.begin(); // init SPI
delay(10);
uint16_t temp_address,Address;
Address = REG_RUN;
digitalWrite(CS_PIN, LOW);
temp_address = ((Address << 4) & 0xFFF0); //shift address to align with cmd packet
SPI.transfer16(temp_address);
SPI.transfer16(ADE9153A_RUN_ON);
Serial.println("DSP ON");
Serial.println(temp_address,HEX);
Serial.println(ADE9153A_RUN_ON,HEX);


digitalWrite(CS_PIN, HIGH);

delay(1000);

Serial.println(MISO);
Serial.println(MOSI);
Serial.println(SCK);
uint16_t temp_address1,Address1;
uint32_t temp_highpacket;
uint16_t temp_lowpacket;
uint32_t returnData;
Address1 = REG_VERSION_PRODUCT;
digitalWrite(CS_PIN, LOW);
temp_address1 = (((Address1 << 4) & 0xFFF0)+8);
SPI.transfer16(temp_address1);
Serial.println(temp_address1,HEX);
temp_highpacket = SPI.transfer16(0x0000);
temp_lowpacket = SPI.transfer16(0x0000);

digitalWrite(CS_PIN, HIGH);
SPI.endTransaction();

returnData = temp_highpacket << 16;
returnData = returnData + temp_lowpacket;
if (returnData != 0x0009153A)
{
Serial.println("Wrong");
Serial.println(temp_highpacket,HEX);
Serial.println(temp_lowpacket,HEX);
//Serial.printf(returnData,HEX);
}
Serial.println("done");

}
void loop() {

delay(100);
}


Can you provide any reference or example : how two connect two feather board using SPI with code and connection diagaram ? in arduino IDE ?

if you will provide simple example of two ESP 32 SPI communication than its very helpfull for me

Looking for your support.

radhey04ec
 
Posts: 7
Joined: Sat Aug 03, 2019 12:41 am

Re: huzzah32 io12 / SPI question

by radhey04ec on Mon Aug 05, 2019 12:01 am

radhey04ec wrote:
adafruit_support_mike wrote:The ESP32 has two ways of routing peripheral signals to the physical pins.

The first one, the GPIO Matrix, can map any signal to any physical pin. There are about 240 possible IO signals, including four separate SPI peripherals.

The second one, the IO_MUX, bypasses the GPIO Matrix and makes connections between specific peripherals and specific pins. Those connections are faster than the GPIO Matrix, and are used by things like the SD card interface and the high-speed SPI peripheral.

GPIO12 is the IO_MUX connection for the HSPI peripheral's MISO signal. You could call it a 'native' connection, but it's more like a special case. The pin defaults to input with a pulldown when the ESP32 reboots, and the ESP32 checks the state of that pin during the boot process to decide how it should operate.

You can use the pin for SPI, but you have to be aware of the pulldown resistor and boot-time signal requirements. It's your job to make sure there are no conflicts that will cause problems.




Hi Dear; :smiley-cry:
I am Jaydeep Shah, from India.

Actually I need your help. I am working on project of ESP32 .
I will have to read slave data using SPI bus. I have checked my cord with Arduino Uno and ESP8266 NODEMCU in Arduino IDE. It works fine.
But when I added ESP32 board and program it accordingly pin details and example suggestion , I did not receive data on SPI.
I have checked with different board Adafruit Huzzah 32 , but result was same.
I have also checked it with Micro python , but still I am unsuccessful.

I know there are multiple SPI BUS.

Can you please suggest How I can solve this problem ? Have you any link/documents regarding this ?
I have searched on GITHUB and Adafruit Forums but still not find proper solution.

If you just clear the topic how initialize SPI for ESP32 , than it become helpful.
I am not worried about programming language. Just need to know how SPI use in ESP32 .
Also suggest how 16 byte and 8 byte data transmit and receive .

If you have any tutorial or code than please provide me it is very helpful.

Looking for your support sir.

My email : radhey04ec@gmail.com

Thanks
Jaydeep shah




adafruit_support_carter wrote:For (2) - yes, see here:
https://learn.adafruit.com/adafruit-huz ... er/pinouts
Also see pin labels on bottom of board:
https://cdn-learn.adafruit.com/assets/a ... 1494445728



I am using FEATHER 32 Board for developing my project Energy meter. I am using SPI interface for communicating with IC.
I have checked following code with Arduino Uno, with Arduino IDE and it works properly.

I have also checked same code with ESP8266 NODEMCU with some changes and it works.

But I want to access live data using Bluetooth, that's why I have used ESP32 Feather board.

But since last 7 days I cant communicate successfully using SPI.

here is my code:

#include <SPI.h>
#define REG_RUN 0x0480
#define ADE9153A_RUN_ON 0x0001
static const int spiClk = 1000000; // 1 MHz
#define REG_VERSION_PRODUCT 0x0242
#define SPI_SCK 5
//uninitalised pointers to SPI objects
#define CS_PIN 2 //8-->Arduino Zero. 15-->ESP8266 Atuall is 16
#define ADE9153A_RESET_PIN 15 //On-board Reset Pin (4)
unsigned int data16;

void setup() {
//initialise two instances of the SPIClass attached to VSPI and HSPI respectively
Serial.begin(115200);
pinMode(ADE9153A_RESET_PIN, OUTPUT);
digitalWrite(ADE9153A_RESET_PIN, HIGH);
digitalWrite(ADE9153A_RESET_PIN, LOW);
delay(100);
digitalWrite(ADE9153A_RESET_PIN, HIGH);
delay(1000);
Serial.println("Reset Done");
//clock miso mosi ss
pinMode(CS_PIN, OUTPUT); // Added this line externally for ESP8266
digitalWrite(CS_PIN, HIGH);
delay(100);
digitalWrite(CS_PIN,LOW);
SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE0)); //set parameters
SPI.begin(); // init SPI
delay(10);
uint16_t temp_address,Address;
Address = REG_RUN;
digitalWrite(CS_PIN, LOW);
temp_address = ((Address << 4) & 0xFFF0); //shift address to align with cmd packet
SPI.transfer16(temp_address);
SPI.transfer16(ADE9153A_RUN_ON);
Serial.println("DSP ON");
Serial.println(temp_address,HEX);
Serial.println(ADE9153A_RUN_ON,HEX);


digitalWrite(CS_PIN, HIGH);

delay(1000);

Serial.println(MISO);
Serial.println(MOSI);
Serial.println(SCK);
uint16_t temp_address1,Address1;
uint32_t temp_highpacket;
uint16_t temp_lowpacket;
uint32_t returnData;
Address1 = REG_VERSION_PRODUCT;
digitalWrite(CS_PIN, LOW);
temp_address1 = (((Address1 << 4) & 0xFFF0)+8);
SPI.transfer16(temp_address1);
Serial.println(temp_address1,HEX);
temp_highpacket = SPI.transfer16(0x0000);
temp_lowpacket = SPI.transfer16(0x0000);

digitalWrite(CS_PIN, HIGH);
SPI.endTransaction();

returnData = temp_highpacket << 16;
returnData = returnData + temp_lowpacket;
if (returnData != 0x0009153A)
{
Serial.println("Wrong");
Serial.println(temp_highpacket,HEX);
Serial.println(temp_lowpacket,HEX);
//Serial.printf(returnData,HEX);
}
Serial.println("done");

}
void loop() {

delay(100);
}


Can you provide any reference or example : how two connect two feather board using SPI with code and connection diagaram ? in arduino IDE ?

if you will provide simple example of two ESP 32 SPI communication than its very helpfull for me

Looking for your support.

radhey04ec
 
Posts: 7
Joined: Sat Aug 03, 2019 12:41 am

Please be positive and constructive with your questions and comments.