I2S MULTIPLEXER

Bu DMA işini yapay zekaya sordum. Yeni bir sürüm çıkarmışlar, "uses advanced reasoning" (ileri seviyede makuldür) :oops: :oops: :oops:

1729000522789.png


Önce 24 saniye düşündü. Bu süreyi de yazdı :katil2: Ve gerçekten çok güzel bir analiz yaptı meret. Bir timer'i harici bir clock ile besle, timer DMA event üretsin, DMA de GPIO data registerini okuyup belleğe yazsın dedi. Ama DMA sadece 16 bit okuyor, o yüzden iki tane DMA kanalı kullan dedi. Yalnız analizi tam bitiremedi, "NVIC configuration" deyip takıldı, ama analiz ettiği kadarı bile baya etkileyici ...

Kod:
Short Answer

Yes, on the STM32 platform, it is possible to configure the DMA controller to read data from two GPIO ports (e.g., GPIOx->IDR registers for P0 and P1), triggered by an external clock signal, and place the values into a circular buffer. Additionally, you can set up the DMA to generate an interrupt when half of the circular buffer size has been received.
Detailed Explanation
1. Overview

The STM32 microcontrollers, particularly those based on the ARM Cortex-M4 core, provide flexible DMA controllers capable of transferring data between peripherals and memory without CPU intervention. While DMA transfers are commonly used with peripherals like ADCs, USARTs, and timers, you can configure the DMA to read from GPIO input data registers (IDR) under certain conditions.
2. Reading GPIO Inputs via DMA

Direct DMA from GPIO:

    GPIO IDR Accessibility: The GPIO input data registers (GPIOx->IDR) can be read like any memory-mapped register.
    DMA Source Address: You can configure the DMA source address to point to the GPIO IDR register.

Considerations:

    Atomicity and Synchronization: Ensure that the GPIO inputs are stable during the DMA read operation to prevent data corruption.
    Data Width: GPIO IDR registers are 32-bit wide, but only the lower 16 bits are valid (for 16 GPIO pins per port). If you need only specific bits, you might need to process the data after transfer.

3. Triggering DMA Transfers with an External Clock Signal

Using a Timer in External Clock Mode:

    Timer Configuration:
        External Clock Mode: Configure a timer (e.g., TIMx) to use an external clock signal on one of its input pins (e.g., ETR or TIx).
        Counter Increment: The timer's counter increments on each external clock pulse.
    DMA Trigger from Timer:
        Update Event DMA Request: Configure the timer to generate a DMA request on every update event (overflow), or
        Capture/Compare DMA Request: Configure the timer to generate a DMA request on each input capture event tied to the external clock.

Process Flow:

    External Clock Signal: The external clock signal drives the timer.
    Timer DMA Requests: The timer generates DMA requests synchronized with the external clock.
    DMA Transfers: The DMA controller performs a transfer for each request, reading from the GPIO IDR and storing the data into the circular buffer.

4. Configuring DMA to Read from Two GPIO Ports

Single DMA Stream for Multiple Ports:

    Not Directly Possible: A single DMA stream cannot read from two non-contiguous memory addresses (e.g., two separate GPIO IDRs) in a single transfer.

Workarounds:

    Use Two DMA Streams:
        Parallel DMA Streams: Configure two DMA streams, each reading from one GPIO port (P0 and P1) and storing into separate buffers.
        Synchronization: Ensure both DMA streams are triggered simultaneously by the same timer event.

    Combine GPIO Ports:
        Use Adjacent Pins: If possible, map P0 and P1 onto the same GPIO port to read both simultaneously.
        Read Combined Data: Configure the DMA to read from a single GPIO IDR, capturing both P0 and P1 in one transfer.

    Memory-Mapped Parallel Inputs:
        External Hardware: Use external hardware (like a latch or bus) to combine the two ports into a single data bus that can be read in one operation.

5. Circular Buffer and Interrupt Generation

DMA Circular Mode:

    Enable Circular Mode: Configure the DMA stream to operate in circular mode, automatically wrapping around the buffer when the end is reached.

Half-Transfer and Transfer Complete Interrupts:

    Half-Transfer Interrupt: Enable the half-transfer interrupt (HTIF) to generate an interrupt when half the buffer is filled.
    Transfer Complete Interrupt: Enable the transfer complete interrupt (TCIF) for notification when the entire buffer is filled.

Interrupt Configuration Steps:

    Enable DMA Interrupts:
        Set the HTIE (Half-Transfer Interrupt Enable) and TCIE (Transfer Complete Interrupt Enable) bits in the DMA stream's configuration register.

    NVIC Configuration:
 
Hatta yukarıdaki DMA metoduna ilave olarak bir de birçok ARM işlemcinin desteklediği "bit banding" teknolojisi kullanılırsa, yani bir bellek bölgesindeki dataların her bir bitine ayrı bir adres ile erişim, bu iş yeterince düşük işlemci cycle ile yapılabilir belki. Denemek lazım :)
 
mikrofonların I2S hatlarını paralel bağlayıp, Enable bacaklarıyla mikrofonları açıp/kapatın?

Kesme sıklığı çok yüksek oluyor, 44.1 kHz için 945 nanosaniyede bir kesme gelir.
 
Kesme sıklığı çok yüksek oluyor, 44.1 kHz için 945 nanosaniyede bir kesme gelir.
Kesme sıklığını herbir kanal için düşünürseniz ~1us çıkıyor ama, tek kesmede paralel okunacağı için kesme sıklığı ~24us olur.
24us de cpu core hızı yeterince yüksekse gerekli hesaplama yapılabilir. Denemek lazım :)
 
inp441 max fsck = 3.2Mhz

Max hızda 24 bit okuma ~7.5us sürer.
Hesaplama vb. diğer işlemler içinde ~17us kadar bir cpu zamanı kalır.

Konu sahibi mkcrofonlar arası mesafeden bahsetti sadece, yerleşim geometrisi hakkında bir detay yok, çizgi gibi dizildiğinde 12 metre gibi bir mesafe ortaya çıkıyor..
Asıl sorun uzak mesafeden bu işareti bu hızda mcuya kadar taşımak.
 
Kesme sıklığını herbir kanal için düşünürseniz ~1us çıkıyor ama, tek kesmede paralel okunacağı için kesme sıklığı ~24us olur.
24us de cpu core hızı yeterince yüksekse gerekli hesaplama yapılabilir. Denemek lazım :)

Örnekleme hızı konusunda konuyu açan herhangi bir bilgi vermediği için varsayımla gidiyoruz. Mesela 44.1 kHz örnekleme hızı varsa, saniyede 44100 x 24 tane 24 bitlik örnek okumamız gerekiyor (mono için, stereo için iki tane 24 bitlik örnek okumak gerekiyor). Portlardan paralel okuma yapıyoruz, ama her bir mikrofondan 1 bit okumuş oluyoruz. O yüzden 44100 x 24 x 24 tane okuma yapmamız gerekiyor saniyede.
 
24 bit okunuyor olsa 44100 Hz orneklenmis olsa 44100 x 24 Hz ile okumak gerekiyor.

24 tanesi paralel oldugu icin mikrofon sayisiin onemi olmuyor.
 

Forum istatistikleri

Konular
6,735
Mesajlar
114,847
Üyeler
2,756
Son üye
Sagankam

Son kaynaklar

Son profil mesajları

hakan8470 wrote on Dede's profile.
1717172721760.png
Dedecim bu gul mu karanfil mi? Gerci ne farkeder onu da anlamam. Gerci bunun anlamini da bilmem :gulus2:
Lyewor_ wrote on hakan8470's profile.
Takip edilmeye başlanmışım :D ❤️
Merhaba elektronik tutsakları...
Lyewor_ wrote on taydin's profile.
Merhabalar. Elektrik laboratuvarınız varsa bunun hakkında bir konunuz var mı acaba? Sizin laboratuvarınızı merak ettim de :)
Back
Top