2022-08-30 01:36 AM
NUCLEO-H743ZI2 board
SAI A1 16bit data, 2 slot as slave.
codec TLV320AIC23BIPW , clock 12MHz, I2S mode 46.8KHz BCLK=3MHz.
I can read the samples of the left channel correctly. I can't read right channel samples.
static void MX_SAI1_Init(void)
{
/* USER CODE BEGIN SAI1_Init 0 */
/* USER CODE END SAI1_Init 0 */
/* USER CODE BEGIN SAI1_Init 1 */
/* USER CODE END SAI1_Init 1 */
hsai_BlockA1.Instance = SAI1_Block_A;
hsai_BlockA1.Init.AudioMode = SAI_MODESLAVE_RX;
hsai_BlockA1.Init.Synchro = SAI_ASYNCHRONOUS;
hsai_BlockA1.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE;
hsai_BlockA1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY;
hsai_BlockA1.Init.SynchroExt = SAI_SYNCEXT_DISABLE;
hsai_BlockA1.Init.MonoStereoMode = SAI_STEREOMODE;
hsai_BlockA1.Init.CompandingMode = SAI_NOCOMPANDING;
hsai_BlockA1.Init.TriState = SAI_OUTPUT_NOTRELEASED;
if (HAL_SAI_InitProtocol(&hsai_BlockA1, SAI_I2S_MSBJUSTIFIED, SAI_PROTOCOL_DATASIZE_16BIT, 2) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN SAI1_Init 2 */
/* USER CODE END SAI1_Init 2 */
}
static void MX_DMA_Init(void)
{
/* DMA controller clock enable */
__HAL_RCC_DMA1_CLK_ENABLE();
/* DMA interrupt init */
/* DMA1_Stream0_IRQn interrupt configuration */
HAL_NVIC_SetPriority(DMA1_Stream0_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(DMA1_Stream0_IRQn);
}
codec init
uint16_t AIC23REGS[]={
0b0001111000000000, //reg15
0b0000000000010111, //reg0
0b0000001000010111, //reg1
0b0000010111111001, //reg2
0b0000011111111001, //reg3
0b0000100000010001, //reg4
0b0000101000000000, //reg5
0b0000110000000000, //reg6
0b0000111001000010, //reg7 data format: I2S format , MSB first, left – 1 aligned
0b0001000000000000, //reg8 AIC23_REG8 46.8KHZ Clock mode select: 0=Normal
0b0001001000000001, //reg9 : digital interface activation
};
I start reading
StatusCodec=HAL_SAI_Receive_DMA(&hsai_BlockA1, pData, Size);
void DMA1_Stream0_IRQHandler(void)
here i found only one channel audio data.
2022-08-30 02:37 AM
> SAI A1 16bit data, 2 slot as slave.
You mean, 8bits left, 8 bits right? Or 16 bit each channel? That's 32 bits altogether.
> if (HAL_SAI_InitProtocol(&hsai_BlockA1, SAI_I2S_MSBJUSTIFIED, SAI_PROTOCOL_DATASIZE_16BIT, 2) != HAL_OK)
Maybe not. Who knows what Cube/HAL exactly does with this.
Read out and check the SAI registers content. Or for ultimate solution, ditch Cube and write those registers yourself. It's only 4 registers or so.
JW
2022-08-30 03:19 AM