using the SPI flash pins for other things

kbaud1
Posts: 71
Joined: Wed Jan 17, 2018 11:55 pm

using the SPI flash pins for other things

Postby kbaud1 » Tue Mar 06, 2018 5:57 pm

I understand the SPI flash pins can be used as general GPIO. But if there is no flash chip connected, the part will not run an application or even possibly boot. So the flash has to be connected. I assume this means that after the part boots and the program is loaded, then the flash pins can be re purposed. How would I prevent the part from trying to access the flash while I am using the pins for something else?

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: using the SPI flash pins for other things

Postby WiFive » Tue Mar 06, 2018 8:55 pm

No, the entire program is not copied to ram and executed. Instead there is a small cache where code from flash gets loaded and executed and this is continually being refreshed.

User avatar
Vader_Mester
Posts: 300
Joined: Tue Dec 05, 2017 8:28 pm
Location: Hungary
Contact:

Re: using the SPI flash pins for other things

Postby Vader_Mester » Wed Mar 07, 2018 12:25 pm

kbaud: Can you explain why you would need those extra pins? Maybe we could provide an alternative solution.

Vader[BEN]

Code: Select all

task_t coffeeTask()
{
	while(atWork){
		if(!xStreamBufferIsEmpty(mug)){
			coffeeDrink(mug);
		} else {
			xTaskCreate(sBrew, "brew", 9000, &mug, 1, NULL);
			xSemaphoreTake(sCoffeeRdy, portMAX_DELAY);
		}
	}
	vTaskDelete(NULL);
}

kbaud1
Posts: 71
Joined: Wed Jan 17, 2018 11:55 pm

Re: using the SPI flash pins for other things

Postby kbaud1 » Wed Mar 07, 2018 11:54 pm

Sure, we have used up all the GPIO and we need these pins for PWM output for motor control.

kbaud1
Posts: 71
Joined: Wed Jan 17, 2018 11:55 pm

Re: using the SPI flash pins for other things

Postby kbaud1 » Wed Mar 07, 2018 11:55 pm

How do can I configure ESP32 to only use SPI dual (not quad) mode for all flash interface during normal program operation and also configure GPIO 9 & 10 for other use? Is this possible to do on ESP-VROOM-32?

ESP_Sprite
Posts: 8926
Joined: Thu Nov 26, 2015 4:08 am

Re: using the SPI flash pins for other things

Postby ESP_Sprite » Thu Mar 08, 2018 4:55 am

You can set that in make menuconfig, 'serial flasher config' -> 'flash SPI mode'; that also configures the runtime configuration. Note that on the ESP-Wrover modules, the GPIOs still are physically connected to the HOLD and WP of the internal flash chip; pulling these flash pins high or low may lead to unexpected results.

User avatar
Vader_Mester
Posts: 300
Joined: Tue Dec 05, 2017 8:28 pm
Location: Hungary
Contact:

Re: using the SPI flash pins for other things

Postby Vader_Mester » Thu Mar 08, 2018 10:41 am

kbaud1 wrote:Sure, we have used up all the GPIO and we need these pins for PWM output for motor control.
You should use a GPIO extender with SPI (or I2C) to use the generaly used GPIO pins, and for PWM and other things use the ESP32.
Additionally, you can use a cheap 8bit microcontroller for GPIO handling.

I suggest this microcontroller (this family). It is an 8bit micro, with 72MHZ clock, SPI master-slave, 14bit ADC, DAC, PWM, etc.
Should be used with the ESP32 as SPI slave.
It also comes with an embeded bootloader, which doesn't require programming equipment just a UART-USB interface.
Price is around $1, so costs nearly nothing.
(Actually this is what I'm planning to use in my project).

Code: Select all

task_t coffeeTask()
{
	while(atWork){
		if(!xStreamBufferIsEmpty(mug)){
			coffeeDrink(mug);
		} else {
			xTaskCreate(sBrew, "brew", 9000, &mug, 1, NULL);
			xSemaphoreTake(sCoffeeRdy, portMAX_DELAY);
		}
	}
	vTaskDelete(NULL);
}

kbaud1
Posts: 71
Joined: Wed Jan 17, 2018 11:55 pm

Re: using the SPI flash pins for other things

Postby kbaud1 » Fri Mar 09, 2018 2:31 am

thank you, I have been looking at the EFM8 actually. already have a dev kit.

Who is online

Users browsing this forum: Bing [Bot], OSCPUDEV and 101 guests