I2S DMA

small coke
Posts: 3
Joined: Fri Apr 03, 2020 2:09 am

I2S DMA

Postby small coke » Fri Apr 03, 2020 2:12 am

I would like to inquire about using I2S to transmit voice. If using DMA, I want to generate an interrupt after the data is transmitted, but I do n’t see the DMA interrupt in the ESP32 technical manual, so I would like to ask the people who have used it to share it. Thank you very much for your experience!

User avatar
Jakobsen
Posts: 85
Joined: Mon Jan 16, 2017 8:12 am

Re: I2S DMA

Postby Jakobsen » Fri Apr 03, 2020 7:31 am

Hi Small Coke

I've done that - It is quite easy just wait for i2s_evt.type == I2S_EVENT_TX_DONE using xQueueReceive(i2s_queue, &i2s_evt, portMAX_DELAY);

The queue handle you will get from you driver install setup call
i2s_driver_install(0, &i2s_config, 10, &i2s_queue);

Let me know if you need more liquor to spice up you coke :-)

/J

Code: Select all

    ...
    double sweepPeriod     = 4;        // in sec  
    uint32_t i = 0;    
    i2s_event_t i2s_evt;
    sweepCnt = 0;
    freq = 50.0;   
    angleSpeed  = 2*M_PI*freq/sampleRate;
    
    while (1) {
        xQueueReceive(i2s_queue, &i2s_evt, portMAX_DELAY);
        if (i2s_evt.type == I2S_EVENT_TX_DONE) 
        { timer_cnt++;
          switch (mode) {
            case 0 : gate = 1;              // Continues 
                     break;
            case 1 :                  // Sweep
                     if (sweepCnt == 0 ) {
                       gate = 1;
                       freq = sweepStartFreq; 
                     } else 
                     { freq = freq * sweepSpeed;
                       angleSpeed = 2*M_PI*freq/sampleRate;
   xQueueReceive(i2s_queue, &i2s_evt, portMAX_DELAY);
        if (i2s_evt.type == I2S_EVENT_TX_DONE) 
                  }
                     if ( freq > sweepStopFreq )
                     { gate = 0;
                       //printf("sweepCnt : %d",sweepCnt);
                       sweepCnt = ( sweepCnt > sweepPeriod*lengthSig) ? 0 : sweepCnt + 1; 
                     } else 
                     { sweepCnt++; 
                     }
      ...
Analog Digital IC designer / DevOps @ Merus Audio, Copenhagen, Denmark.
We do novel and best in class Audio amplifiers for consumer products.
Programmed assembler for C-64 back in 1980's, learned some electronics - hacking since then

small coke
Posts: 3
Joined: Fri Apr 03, 2020 2:09 am

Re: I2S DMA

Postby small coke » Fri Apr 03, 2020 12:51 pm

Thank you very much!I feel you are right, I already have ideas! :D

small coke
Posts: 3
Joined: Fri Apr 03, 2020 2:09 am

Re: I2S DMA

Postby small coke » Sat Apr 04, 2020 6:42 am

Sorry, I still have some problems. I had some ideas according to your statement before, but when I look back and continue to look at the code you provided, I do n’t know if I did n’t understand it or if your code is incomplete. In normal logic, I think your code is missing some braces. Forgive me for being a little white. There may be some offenses between words, sorry! :roll:

User avatar
Jakobsen
Posts: 85
Joined: Mon Jan 16, 2017 8:12 am

Re: I2S DMA

Postby Jakobsen » Sat Apr 04, 2020 8:04 pm

Missing a lot ...

It is only a couple of lines from a signal generator component.

You can check out the full project from the repo :
https://github.com/jorgenkraghjakobsen/sig_gen.git

/j
Analog Digital IC designer / DevOps @ Merus Audio, Copenhagen, Denmark.
We do novel and best in class Audio amplifiers for consumer products.
Programmed assembler for C-64 back in 1980's, learned some electronics - hacking since then

Who is online

Users browsing this forum: No registered users and 15 guests