SAI as I2S at 24bits//192kHz not working on RT1024

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SAI as I2S at 24bits//192kHz not working on RT1024

Jump to solution
2,461 Views
DigitalBrain
Contributor I

Hello.

I'm trying to run PCM4104 DAC at 24bits/192kHz.
So far, I've managed to modify the "evkmimxrt1024_sai_interrupt_transfer" example enough to reproduce the music.h file at 16bits//48kHz but, when "kSAI_WordWidth16bits" is changed to "kSAI_WordWidth24bits" , the 48kHz frequency goes down to 42.68kHz even without changing the sample frequency. 

I've measured with an oscilloscope MCLK and it is being correctly generated in both cases (48 and 42.68 kHz)

I let the system.c and the external libraries to configure I2S as attachment 
Any ideas why is this happening? 

Thanks!!

0 Kudos
Reply
1 Solution
2,149 Views
Habib_MS
NXP Employee
NXP Employee

Hello @DigitalBrain,
In the example the sine wave was sampled for 16 bits and 16Khz, taking this in mind, you can make a new sine wave with the configurations that you are currently working with.

Additionally, you can modify the master clock modifying the dividers. Unfortunately, since the supporting third party devices, such as the PCM4104 is out of scope for the community support. Implementation must come from your side.

BR
Habib

View solution in original post

0 Kudos
Reply
11 Replies
2,432 Views
Habib_MS
NXP Employee
NXP Employee

Hello @DigitalBrain ,

The code that you provided seems fine according with the example called "evkmimxrt1024_sai_interrupt_transfer". In order to try pinpoint if the issue is from the configuration of the I2S where apparently is correct, can you provide me the next signals of I2S transmission?

-BCLK

-MCLK

-WS

In the other hand, I highly recommend see this app note, inside are mentioned a lot of details about how to use I2S in the RT series. Although this app note uses the RT600, is the same to RT1020.

BR
Habib

0 Kudos
Reply
2,407 Views
DigitalBrain
Contributor I

Hello, @Habib_MS 

I've made some testing, changing 63U to 31U :
#define DEMO_SAI3_CLOCK_SOURCE_DIVIDER (31U)

and changing 24bits to 32bits:
#define DEMO_AUDIO_BIT_WIDTH kSAI_WordWidth32bits

makes it possible for the WS to achieve 192kHz without problems.
But when I change it back to 24 bits, WS goes up to 255kHz:

DigitalBrain_3-1730721336358.png


Maybe it has something to do with the word width being distinct to 8/16/32bits?

DigitalBrain_1-1730720225227.png

 (i.MX RT1024 Processor Reference Manual, Rev. 1, 02/2021, page 1582)

 

 

 

 

32bits@192kHz:

DigitalBrain_2-1730721309618.png

 

I've seen this image but I don't understand how should I configure this for 24bits:

DigitalBrain_4-1730721378877.png

 (i.MX RT1024 Processor Reference Manual, Rev. 1, 02/2021, page 1581)


Could you please indicate me how can I proceed?

 

Thanks!

0 Kudos
Reply
2,388 Views
Habib_MS
NXP Employee
NXP Employee

Hello Again @DigitalBrain,
In order to support you better, can you share me the setup that  you are currently using to take the signals? Also, in order to try a pinpoint if this macro solves the issue, can you configure the macro with this value and share me the following signals?

#define DEMO_SAI3_CLOCK_SOURCE_DIVIDER (27U)
-MCLK frequency.
-BITCLK frequency.
-WS frequency.

The bit clock divider is calculated in the function called "SAI_TxSetBitClockRate", inside makes this formula:

Habib_MS_1-1730845926165.png

Where if you set the source clock with a source divider of 31. This bit clock divider will be 2. that causes get more frequency in the WS and the BITCLK. However, if you configure the SAI3_ CLOCK_SOURCE_DIVIDER with 28 the clock divider will be 3.

Also, the next post explains the pictures that you provided me ((i.MX RT1024 Processor Reference Manual, Rev. 1, 02/2021, page 1581))
BR
Habib.

0 Kudos
Reply
2,371 Views
DigitalBrain
Contributor I

Hello, @Habib_MS 
Thanks for getting back to me so quickly

Here's the pinout for the SAI3 module
DigitalBrain_0-1730881164760.png

DigitalBrain_1-1730881505822.png

Configuration: 24bits, 192kHz and #define DEMO_SAI3_CLOCK_SOURCE_DIVIDER (27U)

Results:
-MCLK frequency: 28.11 MHz
-BITCLK frequency: 7.01 MHz
-WS frequency: 146.29 kHz

DigitalBrain_0-1730891621527.png

 

 

0 Kudos
Reply
2,359 Views
DigitalBrain
Contributor I
Furthermore, MCLK (sourceClockHz) = 28.08MHz seems correct but when it comes to BCLK:

bitClockFreq=sampleRate*bitWidth*channelNumbers

bitClockFreq=192kHz*24bits*2=9.216MHz

it should be 9.216MHz according to calculations but I measure 7.012MHz on oscilloscope. I understand WS frequency will be under goal too if this frequency is below desired. Is it correct?
0 Kudos
Reply
2,261 Views
Habib_MS
NXP Employee
NXP Employee

Hello @DigitalBrain,
I will ask internally in order to obtain more information about this issue, I will come back as soon as possible with a response. Thank you for your patience.
BR
Habib

0 Kudos
Reply
2,192 Views
Habib_MS
NXP Employee
NXP Employee

Hello @DigitalBrain,
I asked Internally and shared me the next PLL configurations, additionally you need to configure:
* AUDIO PLL setting: Frequency = Fref * (DIV_SELECT + NUM / DENOM)
* = 24 * (36+ 864/1000)
* = 884.736 MHz

MCLK =Audio root clk= 18.432MHz = 2 * 9.216MHz

However, with this example the master clock is not configurated for PCM4104in, can you share me the datasheet of PCM4104in in order to know how are the requirements for Fs and MCLK?

BR
Habib.

0 Kudos
Reply
2,167 Views
DigitalBrain
Contributor I

Hello, @Habib_MS 

Indeed, the PCM4104 isn't compatible with that MCLK frequency.

I've achieved the next frequencies but still, not getting a clear sine wave at the output.

This is the configuration:

* AUDIO PLL setting: Frequency = Fref * (DIV_SELECT + NUM / DENOM)
* = 24 * (30 + 72/100)
* = 737.28 MHz
*
* = 737.28 MHz / 2 = 368.64 MHz

Then:

/* Select Audio/Video PLL (737.28 MHz) as sai3 clock source */
#define DEMO_SAI3_CLOCK_SOURCE_SELECT (2U)
/* Clock pre divider for sai3 clock source */
#define DEMO_SAI3_CLOCK_SOURCE_PRE_DIVIDER (0U)
/* Clock divider for sai3 clock source */
#define DEMO_SAI3_CLOCK_SOURCE_DIVIDER (9U)
/* Get frequency of sai3 clock */
#define DEMO_SAI_CLK_FREQ \
(CLOCK_GetFreq(kCLOCK_AudioPllClk) / (DEMO_SAI3_CLOCK_SOURCE_DIVIDER + 1U) / \
(DEMO_SAI3_CLOCK_SOURCE_PRE_DIVIDER + 1U))

 

So now it is divided by 10 and it goes down to 36.864 MHz

DigitalBrain_0-1732093586606.png

The frequency for BCLK:
 bitClockFreq = sampleRate * bitWidth * channelNumbers;
 bitClockFreq = 192,000 Hz * 24bits * 2 Channels 
bitClockFreq = 9,216,000 Hz

Finally, the frequency of LRCLK succesfully gets to:
192kHz

DigitalBrain_1-1732093929421.png


I'm writing to the registers of PCM4104 so its configuration is as follows:
Sampling Mode: Quad Rate 
BCK sampling edge= Rising edge
LRCK Polarity: Normal
Audio Format = 0x00 -> 24-bit left justified (default)

without any luck because the output doesn't sound as the example

 



Thank you,
DigitalBrainer

0 Kudos
Reply
2,153 Views
DigitalBrain
Contributor I

Hello, @Habib_MS 

Also, I tried scoping Data output from I2S expecting to see the hexadecimal values from music.h file and I found that the values are transmitted but not on the same order as the const uint8_t music[] __ALIGN_END states.

For example, analyzing some random bytes I expected to read 
0x75, 0x8E, 0xC8, 0x89, 0xC8, 0x89, 0xFD, 0x85, 0xFD
but on the oscilloscope I got:
0xC8, 0x8E,  0x75, 0x89, 0xC8, 0x89, 0xFD, 0x85, 0xFD
as if they were flipped because some reason I don't get:

DigitalBrain_0-1732125013683.png

 

Also, could you please explain why MUSIC_LEN is defined as 48000 in the music.h file from the SDK example?

#define MUSIC_LEN (48000)

I suspect this might be causing no sound output due some format error as the example manages 16bits at 16kHz , not 24bits at 192kHz as I'm trying.


Thanks for your support!

0 Kudos
Reply
2,150 Views
Habib_MS
NXP Employee
NXP Employee

Hello @DigitalBrain,
In the example the sine wave was sampled for 16 bits and 16Khz, taking this in mind, you can make a new sine wave with the configurations that you are currently working with.

Additionally, you can modify the master clock modifying the dividers. Unfortunately, since the supporting third party devices, such as the PCM4104 is out of scope for the community support. Implementation must come from your side.

BR
Habib

0 Kudos
Reply
1,628 Views
DigitalBrain
Contributor I

Thanks! Indeed changing the source file to one sampled at 24bits&192kHz solved the issue

0 Kudos
Reply