STM32 I2S DMA re-initialization problem

Discussions and support about ChibiOS/HAL, the MCU Hardware Abstraction Layer.
Post Reply
king2
Posts: 98
Joined: Mon May 28, 2012 1:57 pm
Been thanked: 2 times

STM32 I2S DMA re-initialization problem

Post by king2 »

I'm tried to write a code that can record some data from UDA1380 chip and play it back (just simple test).
I2S2 is configured to run always because it supplies MCK clock to UDA1380 IC, while I2S3 turns on when recording only.

First sequence (i2sStartExchange/i2sStopExchange) runs OK, but not second one.
In i2s_lld.c function i2s_lld_init() initializes rxdmamode/txdmamode, then i2s_lld_start() function sets mode with dmaStreamSetMode(). All looks like charm at this point.

Then, after I do not need running transfer anymore, I calls i2sStopExchange(), and it calls dmaStreamDisable() at the end, which is resetting STM32_DMA_CR_TCIE|STM32_DMA_CR_HTIE|STM32_DMA_CR_TEIE|STM32_DMA_CR_DMEIE|STM32_DMA_CR_EN flags in DMA stream CR register.

When I call i2sStartExchange again, it is calls dmaStreamEnable(), what sets STM32_DMA_CR_EN only.
So. in second transfer I get all the same except DMA interrupts, so we have failed callbacks, error checking and so on.

I can stop entire service here and re-initialize it, but I think it is mistake in I2S engine, isn't it?
Or this was done for some reason?

Thanks!
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: STM32 I2S DMA re-initialization problem

Post by Giovanni »

hi,

I will look into this problem. It is possible there is a bug because the I2S driver is quite new.

Giovanni
king2
Posts: 98
Joined: Mon May 28, 2012 1:57 pm
Been thanked: 2 times

Re: STM32 I2S DMA re-initialization problem

Post by king2 »

Yes, insertion of

Code: Select all

dmaStreamSetMode(i2sp->dmarx, i2sp->rxdmamode);
dmaStreamSetMode(i2sp->dmatx, i2sp->txdmamode);

into i2s_lld_start_exchange() function in i2c_lld.c (in different places, of course) helped me and now all is working.
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: STM32 I2S DMA re-initialization problem

Post by Giovanni »

Hi,

I fixed it on the repository as bug #630.

Giovanni
Post Reply