How to calculate the I2s clock on esp8266

Hi, i was wondering if someone has a good explanation on how to set the dividers to generate the clock for the i2S on an ESP8266.

it is a bit of an XY here. I want to use DMA to generate 250KHz signal.
I have an example from a clock division for 800KHz & 400KHz

    const static uint32_t I2sClockDivisor = 3;
    const static uint32_t I2sBaseClockDivisor = 16;

        // set the rate
        uint32_t i2s_clock_div = T_SPEED::I2sClockDivisor & I2SCDM;
        uint8_t i2s_bck_div = T_SPEED::I2sBaseClockDivisor & I2SBDM;

        I2SC |= I2SRF | I2SMR | I2SRSM | I2SRMS | (i2s_bck_div << I2SBD) | (i2s_clock_div << I2SCD);

Apologies for the snippet, there is something missing (the T_SPEED macro ? is it ?)
Anyway it comes from a library that uses DMA but if someone knows how to calculate the BaseClockDivisor & ClockDivisor and / or can give me a somewhat clear explanation on how it is done.
For a UART they usually provide some kind of table, here i had difficulty finding any other info then "It is made up out of 3 ? values' But nowhere an indication of how it is done.

So Ok i think i anyway got it from here . I had looked at it before, but it didn't click.
The clock = 160 / I2sBaseClockDivisor / I2sClockDivisor
The example was actually from WS2811 library, and then it uses a clock at 4x the speed to generate the waveform.
Then it made sense. 160 / 16 / 3 = 3.3MHz which is 4x a bit over 800KHz.

Anyway, if i would want to set it to 250Kbps normal signal, i would do 160 / 16/ 40 and that would get me the .25MHz i want Hmm it's worth a go.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.