SAI_TxSetBitClockRate parameter questions

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

SAI_TxSetBitClockRate parameter questions

Jump to solution
1,313 Views
davenadler
Senior Contributor II

I'm trying to set up SAI (send only, as master).
But I'm confused by the SAI_TxSetBitClockRate parameters, documented as:

 

/*!
 * brief Transmitter bit clock rate configurations.
 *
 * param base SAI base pointer.
 * param sourceClockHz, bit clock source frequency.
 * param sampleRate audio data sample rate.
 * param bitWidth, audio data bitWidth.
 * param channelNumbers, audio channel numbers.
 */
void SAI_TxSetBitClockRate(
    I2S_Type *base, uint32_t sourceClockHz, uint32_t sampleRate, uint32_t bitWidth, uint32_t channelNumbers)

 

1) What is uint32_t channelNumbers?
In the code this seems to be used as numberOfChannels (ie 2 for stereo):

 

uint32_t bitClockFreq = sampleRate * bitWidth * channelNumbers;

 

2) What is uint32_t sourceClockHz?
Is this just the module's clock input, as generated by the clock tool, ie

 

#define BOARD_BOOTCLOCKRUN_SAI1_CLK_ROOT              63529411UL

 

Thanks in advance,
Best Regards, Dave

 

 

0 Kudos
Reply
1 Solution
1,286 Views
Gavin_Jia
NXP TechSupport
NXP TechSupport

Hi @davenadler ,

Thanks for your interest in NXP MIMXRT series!

1) What is uint32_t channelNumbers?
In the code this seems to be used as numberOfChannels (ie 2 for stereo):

>> Yes, you are right.

2) What is uint32_t sourceClockHz?
Is this just the module's clock input, as generated by the clock tool, ie

>> Yes. It is the clock frequency of the SAI peripheral. It is used to configure the appropriate BCLK.

 

View solution in original post

0 Kudos
Reply
1 Reply
1,287 Views
Gavin_Jia
NXP TechSupport
NXP TechSupport

Hi @davenadler ,

Thanks for your interest in NXP MIMXRT series!

1) What is uint32_t channelNumbers?
In the code this seems to be used as numberOfChannels (ie 2 for stereo):

>> Yes, you are right.

2) What is uint32_t sourceClockHz?
Is this just the module's clock input, as generated by the clock tool, ie

>> Yes. It is the clock frequency of the SAI peripheral. It is used to configure the appropriate BCLK.

 

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2002352%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ESAI_TxSetBitClockRate%20parameter%20questions%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2002352%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EI'm%20trying%20to%20set%20up%20SAI%20(send%20only%2C%20as%20master).%3CBR%20%2F%3EBut%20I'm%20confused%20by%20the%20SAI_TxSetBitClockRate%20parameters%2C%20documented%20as%3A%3C%2FP%3E%3CBR%20%2F%3E%3CPRE%20class%3D%22lia-code-sample%20language-c%22%3E%3CCODE%3E%2F*!%0A%20*%20brief%20Transmitter%20bit%20clock%20rate%20configurations.%0A%20*%0A%20*%20param%20base%20SAI%20base%20pointer.%0A%20*%20param%20sourceClockHz%2C%20bit%20clock%20source%20frequency.%0A%20*%20param%20sampleRate%20audio%20data%20sample%20rate.%0A%20*%20param%20bitWidth%2C%20audio%20data%20bitWidth.%0A%20*%20param%20channelNumbers%2C%20audio%20channel%20numbers.%0A%20*%2F%0Avoid%20SAI_TxSetBitClockRate(%0A%20%20%20%20I2S_Type%20*base%2C%20uint32_t%20sourceClockHz%2C%20uint32_t%20sampleRate%2C%20uint32_t%20bitWidth%2C%20uint32_t%20channelNumbers)%3C%2FCODE%3E%3C%2FPRE%3E%3CBR%20%2F%3E%3CP%3E%3CSTRONG%3E1)%20What%20is%20uint32_t%20channelNumbers%3F%3C%2FSTRONG%3E%3CBR%20%2F%3EIn%20the%20code%20this%20seems%20to%20be%20used%20as%20numberOfChannels%20(ie%202%20for%20stereo)%3A%3C%2FP%3E%3CBR%20%2F%3E%3CPRE%20class%3D%22lia-code-sample%20language-c%22%3E%3CCODE%3Euint32_t%20bitClockFreq%20%3D%20sampleRate%20*%20bitWidth%20*%20channelNumbers%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CBR%20%2F%3E%3CP%3E%3CSTRONG%3E2)%20What%20is%20uint32_t%20sourceClockHz%3F%3CBR%20%2F%3E%3C%2FSTRONG%3EIs%20this%20just%20the%20module's%20clock%20input%2C%20as%20generated%20by%20the%20clock%20tool%2C%20ie%3C%2FP%3E%3CBR%20%2F%3E%3CPRE%20class%3D%22lia-code-sample%20language-c%22%3E%3CCODE%3E%23define%20BOARD_BOOTCLOCKRUN_SAI1_CLK_ROOT%20%20%20%20%20%20%20%20%20%20%20%20%20%2063529411UL%3C%2FCODE%3E%3C%2FPRE%3E%3CBR%20%2F%3E%3CP%3EThanks%20in%20advance%2C%3CBR%20%2F%3EBest%20Regards%2C%20Dave%3C%2FP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2002674%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%20SAI_TxSetBitClockRate%20parameter%20questions%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2002674%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F132425%22%20target%3D%22_blank%22%3E%40davenadler%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%0A%3CP%3EThanks%20for%20your%20interest%20in%20NXP%20MIMXRT%20series!%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E1)%20What%20is%20uint32_t%20channelNumbers%3F%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSPAN%3EIn%20the%20code%20this%20seems%20to%20be%20used%20as%20numberOfChannels%20(ie%202%20for%20stereo)%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26gt%3B%26gt%3B%20Yes%2C%20you%20are%20right.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CSTRONG%3E2)%20What%20is%20uint32_t%20sourceClockHz%3F%3CBR%20%2F%3E%3C%2FSTRONG%3EIs%20this%20just%20the%20module's%20clock%20input%2C%20as%20generated%20by%20the%20clock%20tool%2C%20ie%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26gt%3B%26gt%3B%20Yes.%26nbsp%3B%3C%2FSPAN%3EIt%20is%20the%20clock%20frequency%20of%20the%20SAI%20peripheral.%20It%20is%20used%20to%20configure%20the%20appropriate%20BCLK.%3C%2FP%3E%0A%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E