2020-09-21 08:40 PM
I am writing a simple code. Receiving ADC data from I2S3. (ADC is PCM1808 and 96kHz Stereo 24bit in 32bit frame, I2S Philips)
Buffers:
uint16_t ADC_Data [BUF_LEN*2*2*2] ; // 16bit*2 * stereo * double buffer (I2S buffer)
int32_t ADC1_Data[BUF_LEN*2*2] ; // (4byte) * stereo * double buffer (output data converted from 0-2^24 to +/- 2^23)
After initialization, start I2S with DMA mode.
HAL_I2S_Receive_DMA(&hi2s3, (uint16_t *) ADC_Data, (uint16_t) (BUF_LEN*2) * 4) ;
Then, Callback
void HAL_I2S_RxHalfCpltCallback(I2S_HandleTypeDef * hi2s3) {
for (int i=0 ; i < BUF_LEN*2; i++) {
ADC1_Data[i] = (((int32_t) ADC_Data[i*2] << 8) | ((ADC_Data[i*2+1] >>8) & 0x0FF)) - 8388608 ; // Adjust to zero (2^23)
// ***** ADC_Data[i*2] does not load correct value (or from wrong Address, I suppose.)
}
ADC1_ptr = BUF_LEN*2 ;
//***** After return from callback, Hard fault occurs. (DMA Xfer Error)
}
Code is Simple, and I do not find any trouble in Sending Data with I2S or SPI.
Kindly teach me what is wrong with my code. (or complier).
2020-10-19 02:58 AM
Hello @KAJIK.1
Could you please share your .IOC file to check with.
Best regards,
Nesrine
2020-10-19 11:56 AM