ESP-WROVER-KIT GPIO problem.

User avatar
PaulVdBergh
Posts: 58
Joined: Fri Feb 23, 2018 4:45 pm
Location: Brasschaat, Belgium

ESP-WROVER-KIT GPIO problem.

Postby PaulVdBergh » Wed Feb 28, 2018 3:19 pm

Hi all,

Im in trouble configuring/using GPIO pins on the ESP-WROVER-KIT.
code fragment :

Code: Select all

	DCCGen::DCCGen(	gpio_num_t RailcomGPIONum /* = GPIO_NUM_16 */,
					gpio_num_t PowerGPIONum /* = GPIO_NUM_17 */,
					gpio_num_t DccGPIONum /* = GPIO_NUM_18 */,
					rmt_channel_t channel /* = RMT_CHANNEL_0 */
				  )
	:	m_bContinue(true)
	,	m_PowerState(PowerOn)
	,	m_PowerGPIONum(PowerGPIONum)
	,	m_RailcomGPIONum(RailcomGPIONum)
	,	m_DccGPIONum(DccGPIONum)
	,	m_Channel(channel)
	{
		memset(&m_gpioConfig, 0, sizeof(gpio_config_t));

		m_gpioConfig.pin_bit_mask = ((1ULL << m_RailcomGPIONum) | (1ULL << m_PowerGPIONum));
		m_gpioConfig.mode = GPIO_MODE_OUTPUT;
		m_gpioConfig.pull_up_en = GPIO_PULLUP_ENABLE;
		m_gpioConfig.pull_down_en = GPIO_PULLDOWN_DISABLE;
		m_gpioConfig.intr_type = GPIO_INTR_DISABLE;

		ESP_ERROR_CHECK(gpio_config(&m_gpioConfig));

		ESP_ERROR_CHECK(gpio_set_level(m_PowerGPIONum, 0));
		ESP_ERROR_CHECK(gpio_set_level(m_RailcomGPIONum, 0));
		.
		.	(some other irrelevant code)
		.
		m_thread = thread([this]{threadFunc();});
	}
	
	void DCCGen::threadFunc()
	{
		.
		.	(other irrelevant code)
		.
		while(m_bContinue)
		{
			//	send the preamble_items
			ESP_ERROR_CHECK(rmt_write_items(m_rmtConfig.channel, preamble_items, PREAMBLE_NBR_CYCLES, false));

			// meanwhile  (we have 1856 µS to spend...)
			usleep(28);
			//	Shutdown power
			gpio_set_level(m_PowerGPIONum, 0);
			usleep(2);
			//	Short the outputs
			gpio_set_level(m_RailcomGPIONum, 1);
			usleep(439);
			//	un-Short outputs
			gpio_set_level(m_RailcomGPIONum, 0);
			usleep(2);
			//	Power up Power
			if(m_PowerState == PowerOn)
			{
				gpio_set_level(m_PowerGPIONum, 1);
			}


			if(nullptr == (pNextMessage = getNextDccMessage()))
			{
				pNextMessage = &IdleMessage;
			}

			ItemCount = pNextMessage->getItemCount();
			ItemCount = (ItemCount > 64) ? 64 : ItemCount;
			memcpy(pItems, pNextMessage->getItems(), ItemCount * sizeof(rmt_item32_t));

			//	wait until preamble finished
			ESP_ERROR_CHECK(rmt_wait_tx_done(m_rmtConfig.channel, PREAMBLE_WAIT_TIME));

			//	send dcc data and wait until end of transmission
			ESP_ERROR_CHECK(rmt_write_items(m_rmtConfig.channel, pItems, ItemCount, true));
		}

		ESP_ERROR_CHECK(rmt_driver_uninstall(m_rmtConfig.channel));
	}
}	//	namespace TBTIoT
I cannot figure out how to make the gpio's work. The signal from the rmt peripheral on gpio18 is exact as I intended, but no activity on GPIO 16 nor 17... (with logic analyser).

Am I missing some initialisation? Has it something to do with multithreading ? I'm looking at nkolban's github site and find no missing links in my program.

Thanks in advance,

Paul

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

Re: ESP-WROVER-KIT GPIO problem.

Postby ESP_Sprite » Thu Mar 01, 2018 1:10 am

It depends on your ESP-WROVER-KIT module. If it's an older one, fitted with an ESP-WROOM32, you should be able to use those two pins. If the module is the ESP-WROVER module (with 4MiB of PSRAM inside), GPIO16 and 17 are used to control the PSRAM and can't be used externally.

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

Re: ESP-WROVER-KIT GPIO problem.

Postby WiFive » Thu Mar 01, 2018 3:20 am

Driver(s) should be updated to return error if gpio conflict w/ detectable hw configurations

User avatar
PaulVdBergh
Posts: 58
Joined: Fri Feb 23, 2018 4:45 pm
Location: Brasschaat, Belgium

Re: ESP-WROVER-KIT GPIO problem.

Postby PaulVdBergh » Thu Mar 01, 2018 9:30 am

ESP_Sprite wrote:It depends on your ESP-WROVER-KIT module. If it's an older one, fitted with an ESP-WROOM32, you should be able to use those two pins. If the module is the ESP-WROVER module (with 4MiB of PSRAM inside), GPIO16 and 17 are used to control the PSRAM and can't be used externally.
Ok, Thanks. I changed to GPIO0, 2 & 4 and now it works. Where can I find info re which pins are in use (by which subsystem) and what pins are free to use?

Paul

User avatar
ESP_krzychb
Posts: 400
Joined: Sat Oct 01, 2016 9:05 am
Contact:

Re: ESP-WROVER-KIT GPIO problem.

Postby ESP_krzychb » Thu Mar 01, 2018 9:42 am

PaulVdBergh wrote:Where can I find info re which pins are in use (by which subsystem) and what pins are free to use?
Hi Paul,

It is documented in https://esp-idf.readthedocs.io/en/lates ... esp32-pins

Who is online

Users browsing this forum: No registered users and 65 guests