谢谢香水城,从手册里看在I2S做主发送数据,MCLK输出与否根据需求,可以设置为关闭如手册上面的表和下面的描述:
I2S master mode
The I2S can be configured in master mode for transmission and reception. This means that
the serial clock is generated on the CK pin as well as the Word Select signal WS. Master
clock (MCK) may be output or not, thanks to the MCKOE bit in the SPI_I2SPR register.
软件里面,这部分是在初始化里做的:
static void I2SOUT_Init(uint32_t AudioFreq)
{
/* Initialize the hAudioOutI2s Instance parameter */
hAudioOutI2s.Instance = I2SOUT;
/* Disable I2S block */
__HAL_I2S_DISABLE(&hAudioOutI2s);
/* Perform MSP initialization at first function call */
if(HAL_I2S_GetState(&hAudioOutI2s) == HAL_I2S_STATE_RESET)
{
I2SOUT_MspInit();
}
/* I2SOUT peripheral configuration */
hAudioOutI2s.Init.AudioFreq = AudioFreq;
hAudioOutI2s.Init.CPOL = I2S_CPOL_LOW;
hAudioOutI2s.Init.DataFormat = I2S_DATAFORMAT_16B;
hAudioOutI2s.Init.MCLKOutput = I2S_MCLKOUTPUT_DISABLE; //////////就这个语句,enable是完全正常,disable就不行
// hAudioOutI2s.Init.MCLKOutput = I2S_MCLKOUTPUT_ENABLE;
hAudioOutI2s.Init.Mode = I2S_MODE_MASTER_TX;
hAudioOutI2s.Init.Standard = I2S_STANDARD;
/* Initialize the I2S peripheral with the structure above */
HAL_I2S_Init(&hAudioOutI2s);
}
ODD DIV配置例程代码里对有没有MCKOE使能已经做了:
/* Compute the Real divider depending on the MCLK output state, with a floating point */
if(hi2s->Init.MCLKOutput == I2S_MCLKOUTPUT_ENABLE)
{
/* MCLK output is enabled */
tmp = (uint32_t)(((((i2sclk / 256) * 10) / hi2s->Init.AudioFreq)) + 5);
}
else
{
/* MCLK output is disabled */
tmp = (uint32_t)(((((i2sclk / (32 * packetlength)) *10 ) / hi2s->Init.AudioFreq)) + 5);
}
/* Remove the flatting point */
tmp = tmp / 10;
/* Check the parity of the divider */
i2sodd =(uint32_t)(tmp & (uint32_t)1);
/* Compute the i2sdiv prescaler */
i2sdiv =(uint32_t)((tmp - i2sodd) / 2);
/* Get the Mask for the Odd bit (SPI_I2SPR[8]) register */
i2sodd = (uint32_t) (i2sodd << 8);
从资料了和官方代码里看,均可以直接开关MCLK的,希望大能指点
|