-
Notifications
You must be signed in to change notification settings - Fork 7.8k
HSPI is not working above Board Manager 2.0.3 #8822
-
Hi,
Windows 11
Arduino 1.8.19
Chip ESP32-PICO-D4
I was using ICM-20948 with SPI interface on HSPI on ESP32-PICO-D4 chipset. Till now I was on ESP version 1.0.6 and as now I wanted to upgrade the board manager I realize that after 2.0.3 HSPI is not working as code compiles fine but execution is halted after begin.
here is my initialization
SPIClass hspi;
ICM_20948_SPI ICM; // If using SPI create an ICM_20948_SPI object
hspi = SPIClass(HSPI);
hspi.begin(14 /* SCK /, 12 / MISO /, 13 / MOSI /, 25/ SS */);
ICM.begin(ICM_CS_PIN, hspi);
ICM.begin calles the code given bellow.
Here is the ICM library code and it never goes after
_spi->beginTransaction(_spisettings);
_spi->transfer(0x00);
_spi->endTransaction();
ICM_20948_Status_e ICM_20948_SPI::begin(uint8_t csPin, SPIClass& spiPort, uint32_t SPIFreq)
{
if (SPIFreq > 7000000)
SPIFreq = 7000000;
// Associate
_spi = &spiPort;
_spisettings = SPISettings(SPIFreq, ICM_20948_SPI_DEFAULT_ORDER, ICM_20948_SPI_DEFAULT_MODE);
_cs = csPin;
// Set pinmodes
pinMode(_cs, OUTPUT);
// Set pins to default positions
digitalWrite(_cs, HIGH);
// _spi->begin(); // Moved into user's sketch
// 'Kickstart' the SPI hardware.
_spi->beginTransaction(_spisettings);
_spi->transfer(0x00);
_spi->endTransaction();
Serial.println("This Never Prints");
// Set up the serif
_serif.write = ICM_20948_write_SPI;
_serif.read = ICM_20948_read_SPI;
_serif.user = (void*)this; // refer to yourself in the user field
// Link the serif
_device._serif = &_serif;
// Perform default startup
status = startupDefault();
if (status != ICM_20948_Stat_Ok)
{
return status;
}
return ICM_20948_Stat_Ok;
}
Is there any workaround to get HSPI working as I already have SD Card on VSPI?
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 2 comments 5 replies
-
I'm using VSPI and HSPI with Arduino Core 2.0.7 with no issue.
#include "SPI.h" //Creates "SPI" object
#define SPI3 SPI //Alias to make it easier to keep track of SPI ports. This is actually in my header file.
SPIClass SPI2(HSPI); //Create SPI2 object
SPI2.begin( 14, //SPI2 clk
34, //SPI2 input unused
13,
-1); //CS unused
SPI3.begin( 18, //SPI3 clk. Custom hardware!
35, //SPI3 input unused
23,
-1); //CS unused
SPI3.beginTransaction(SPISettings(8000000, 1, 0));
SPI3.transfer(_canvas[i + offset_row_D]);
SPI3.transfer(_canvas[i + offset_row_C]);
SPI3.transfer(_canvas[i + offset_row_B]);
SPI3.transfer(_canvas[i]);
SPI3.endTransaction();
I think I read somewhere that only one SPI port can use nCS. Hope this helps!
Beta Was this translation helpful? Give feedback.
All reactions
-
Never name SPI objects in ESP32-Arduino as SPIx, because those do exist as pointer to the bus registers for at least some of the chips.
Beta Was this translation helpful? Give feedback.
All reactions
-
Good to know! I will change my code to _SPI2, _SPI3.
Beta Was this translation helpful? Give feedback.
All reactions
-
Here as @me-no-dev said I am not using SPIx as I have
hspi = SPIClass(HSPI);
But only difference now is I am passing nCS pin when I init SPI with here
hspi.begin(14 /* SCK /, 12 / MISO /, 13 / MOSI /, 25/ SS */);
So Now let me put -1 and try with latest 2.0.14 version then?
Beta Was this translation helpful? Give feedback.
All reactions
-
I look forward to hearing the result
Beta Was this translation helpful? Give feedback.
All reactions
-
I have updated to 2.0.7 as well as 2.0.11 and 2.0.14 but it's not working.
Here is code attached. It Compiles fine with each verison but works only with 2.0.3
ESP_ICM_HSPI.zip
Beta Was this translation helpful? Give feedback.
All reactions
-
Got it working
from this code
SPIClass hspi;
ICM_20948_SPI ICM; // If using SPI create an ICM_20948_SPI object
hspi = SPIClass(HSPI);
hspi.begin(14 /* SCK /, 12 / MISO /, 13 / MOSI /, 25/ SS */);
ICM.begin(ICM_CS_PIN, hspi);
I removed
hspi = SPIClass(HSPI);
and it worked.
Beta Was this translation helpful? Give feedback.