I2S driving H-Bridge troubles

CollinK
Posts: 18
Joined: Mon Apr 16, 2018 11:38 pm

I2S driving H-Bridge troubles

Postby CollinK » Wed Apr 15, 2020 1:19 am

So, the basic gist of it is that I'm outputting on four pins to drive the four inputs to an H-bridge. You ask, why didn't I output two pins only? Because I want the h-bridge to be able to idle too. So, four pins it is, one to each transistor gate, idling means the P-channel mosfets are held high and the N-channel low. I'm using DMA and I2S to do this. The whole operation is extremely fast too, the I2S output is at 16MHz. The reason is that I'm not actually doing PWM which would make the motor control PWM outputs on the ESP32 the way to go. Instead I'm doing something different and custom so I want to fully control the state of all four pins. Also, I'm not sure the PWM module would like 16Mhz output. That's a lot faster than people are normally driving h-bridges at. As I'm sure you can imagine, I'm not really driving a motor at that speed - this is really a custom waveform. It's working for the most part. I get the output I want on the pins for the most part. At the end of each DMA buffer I have the pins going to the idle state and after transmission it stays in the idle state like I want. However, if I then try to send again nothing happens. I have to reset the hardware with code like this:

Code: Select all

	
	volatile i2s_dev_t &i2s = *i2sDevices[i2sIndex];

	//DMA config register
	const unsigned long lc_conf_reset_flags = I2S_IN_RST_M | I2S_OUT_RST_M | I2S_AHBM_RST_M | I2S_AHBM_FIFO_RST_M;
	i2s.lc_conf.val |= lc_conf_reset_flags;
	i2s.lc_conf.val &= ~lc_conf_reset_flags;


	//general config register
	const uint32_t conf_reset_flags = I2S_TX_RESET_M ;//| I2S_RX_RESET_M ;//| I2S_RX_FIFO_RESET_M | I2S_TX_FIFO_RESET_M;
	i2s.conf.val |= conf_reset_flags;
	i2s.conf.val &= ~conf_reset_flags;
	while (i2s.state.tx_fifo_reset_back);
Doing so causes it to properly send a DMA buffer the next time I need to. Otherwise nothing is sent. However, calling the above code causes a 1us delay where the line states all go low. So, if I call the reset code just before sending I'll get about 1-1.25us of all low pin states followed by the proper digital signal being sent. This causes both P-channel mosfets to turn on. This isn't fatal to me but it isn't right either. I want the pins to stay in the state I left them in until I next send a new state. I don't want to have to reset the hardware every time I'm about to send another buffer. I've checked the interrupt registers, nothing is changing, I've checked the config registers, they all look good as far as I can tell. Is it normal to have to reset everything before the start of a DMA transfer? Is there a better way to output arbitrary digital signals at high speed? The 16Mhz output speed would seem to limit my options a bit.

CollinK
Posts: 18
Joined: Mon Apr 16, 2018 11:38 pm

Re: I2S driving H-Bridge troubles

Postby CollinK » Sat Apr 18, 2020 7:33 pm

Soooo, nothing? It appears to me that everyone does do a reset of the hardware before doing an output from I2S again so it looks like maybe you have to. But, no confirmation on that? And, why should it be necessary? The hardware can't be trusted to work properly without constantly resetting it?

Who is online

Users browsing this forum: No registered users and 27 guests