Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I2S master clock not working in transmit mode #685

Open
JosefUtbult opened this issue Oct 3, 2023 · 4 comments
Open

I2S master clock not working in transmit mode #685

JosefUtbult opened this issue Oct 3, 2023 · 4 comments

Comments

@JosefUtbult
Copy link

Hello.

I've been trying to get an I2S transmit stream to work. I've been using the following configuration from the i2s-audio-out example.

let i2s_transmit = I2s::new(codec.spi2, i2s_transmit_pins, codec.clocks);

// Setup Master device for configurations codec
let i2s_transmit_config = I2sDriverConfig::new_master()
    .receive()
    .standard(Philips)
    .data_format(DataFormat::Data24Channel32)
    .master_clock(true)
    .request_frequency(48_000);

let mut i2s_transmit_driver = I2sDriver::new(i2s_transmit, i2s_transmit_config);
defmt::info!("Actual sample rate is {}", i2s_transmit_driver.sample_rate());

i2s_transmit_driver.enable();

Which generates a functioning master clock output on pin C6. The problem though is that this master clock doesn't function when I'm changing it to transmit mode.

let i2s_transmit = I2s::new(codec.spi2, i2s_transmit_pins, codec.clocks);

// Setup Master device for configurations codec
let i2s_transmit_config = I2sDriverConfig::new_master()
    .transmit()
    .standard(Philips)
    .data_format(DataFormat::Data24Channel32)
    .master_clock(true)
    .request_frequency(48_000);

let mut i2s_transmit_driver = I2sDriver::new(i2s_transmit, i2s_transmit_config);
defmt::info!("Actual sample rate is {}", i2s_transmit_driver.sample_rate());

i2s_transmit_driver.enable();

Is this a problem with how the STM32 works, or is it something thats missing in the HAL? Thanks in advance

@burrbull
Copy link
Member

burrbull commented Oct 3, 2023

cc @YruamaLairba

@YruamaLairba
Copy link
Contributor

@JosefUtbult not sure, but i think clocks are generated only when data are send, So you don't see any clock signal until you send data.

@JosefUtbult
Copy link
Author

Good call. The problem was in that I didn't send any data to start with. Now the problem lays in that the codec I'm using needs a master clock signal in order to be accessable over i2c for configuration. I solved it by configuring it as a i2s receive with a master clock, wrote the configuration over i2c and then reconfigured it to a i2s transmit. Thanks for the help

@YruamaLairba
Copy link
Contributor

@JosefUtbult What codec do you use ? Are you sure to not confuse I2s Master clock with I2c Master clock ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants