Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

HSPI is not working above Board Manager 2.0.3 #8822

Closed Unanswered
iharshadec asked this question in Q&A
Discussion options

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?

You must be logged in to vote

Replies: 2 comments 5 replies

Comment options

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!

You must be logged in to vote
5 replies
Comment options

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.

Comment options

Good to know! I will change my code to _SPI2, _SPI3.

Comment options

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?

Comment options

I look forward to hearing the result

Comment options

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

Comment options

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.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /