cancel
Showing results for 
Search instead for 
Did you mean: 

['F446 Cube/documentation] SAIxy_CR1.CKSTR

Posted on January 03, 2018 at 22:43

0690X00000609LgQAI.png

For I2S, data are latched on the falling edge of CK (for the transmitter) and are read on the rising

edge (for the receiver). That, according to CKSTR's description above, means to set CKSTR=1 for both transmitter and receiver.

However, [STM32Cube_FW_F4_V1.18.0]\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_sai.c has this to say in HAL_StatusTypeDef SAI_InitI2S():

  /* Compute ClockStrobing according AudioMode */

  if((hsai->Init.AudioMode == SAI_MODEMASTER_TX) || (hsai->Init.AudioMode == SAI_MODESLAVE_TX))

  { /* Transmit */

    hsai->Init.ClockStrobing     = SAI_CLOCKSTROBING_FALLINGEDGE;

  }

  else

  { /* Receive */

    hsai->Init.ClockStrobing     = SAI_CLOCKSTROBING_RISINGEDGE;

  }

So, either the code in Cube, or the description in RM, is wrong.

Which one is it?

JW

2 REPLIES 2
Imen.D
ST Employee
Posted on June 13, 2018 at 11:56

Hello

Waclawek.Jan

,

Since in I2S protocol Data are latched on the falling edge of CK (for transmitter) and are read on the rising edge

(for the receiver), the corresponding code in Cube is ok and aligned with the reference manual.

/* Transmit */

hsai->Init.ClockStrobing = SAI_CLOCKSTROBING_FALLINGEDGE;

--> ckstr_bits = 1 (refer to HAL_SAI_Init)

/* Receive */

hsai->Init.ClockStrobing = SAI_CLOCKSTROBING_RISINGEDGE;

--> ckstr_bits = 0 (refer to HAL_SAI_Init) In HAL_SAI_Init the code above is used for setting the CKSTR bit:

/* Compute CKSTR bits of SAI CR1 according to ClockStrobing and AudioMode */

if((hsai->Init.AudioMode == SAI_MODEMASTER_TX) || (hsai->Init.AudioMode == SAI_MODESLAVE_TX))

{ /* Transmit */

ckstr_bits = (hsai->Init.ClockStrobing == SAI_CLOCKSTROBING_RISINGEDGE) ? 0U: SAI_xCR1_CKSTR;

}

else

{ /* Receive */

ckstr_bits = (hsai->Init.ClockStrobing == SAI_CLOCKSTROBING_RISINGEDGE) ? SAI_xCR1_CKSTR: 0U;

}

Best Regards,

Imen.

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Posted on June 13, 2018 at 12:25

Oh, I see, so in Cube/HAL you use a different definition of what is 'strobing' than in the RM... This kind of logic is impenetrable for me.

Thanks for the explanation.

Jan