CubeIDE generates wrong code for I2S_RxCpltCallback and Hard Fault (DMA Xfer Error)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-09-21 8: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).
- Labels:
-
DMA
-
I2S
-
STM32CubeMX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-10-19 2:58 AM
Hello @KAJIK.1​
Could you please share your .IOC file to check with.
Best regards,
Nesrine
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-10-19 11:56 AM
Thank you very much for your kind offer.
However, I found the reason of this problem, and I sent the ST Community my request.
Request to revise I2S section of HAL document. (UM1725)
https://community.st.com/s/question/0D73W000000Unty/detail?s1oid=00Db0000000YtG6&s1nid=0DB0X000000DYbd&emkind=chatterCommentNotification&s1uid=0053W000000y1LV&emtm=1601385662492&fromEmail=1&s1ext=0
But if you have time, please check my another post.
STM32F4 Is this BUG?
I2S LOOP BACK TEST FAILS in 24Bit Mode. Crush DMA pointer etc. (source code attached)
https://community.st.com/s/question/0D73W000000UlmR/detail?s1oid=00Db0000000YtG6&s1nid=0DB0X000000DYbd&emkind=chatterCommentNotification&s1uid=0053W000000y1LV&emtm=1601019780337&fromEmail=1&s1ext=0
I wrote I2S Loop-Back test program, Sending Audio data (1kHz (left), 2kHz (right)) to I2S2, and Receiving the same data from I2S3.
And I got 1-Bit Shifted data from I2S3 (input).
Thank you,
Ajika
