RT1052 MQS Clock Frequencies

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

RT1052 MQS Clock Frequencies

Jump to solution
1,942 Views
variable_andrew
Senior Contributor I

My goal is to use the MQS (so from SAI3 as I understand) to generate some mono 8 bit sounds

I'm basing my code off of the sai_interrupt demo from the MCUXpresso SDK.

Could you explain why exactly these clock dividers were selected for the demo?

/* Select Audio/Video PLL (786.48 MHz) as sai1 clock source */
#define DEMO_SAI1_CLOCK_SOURCE_SELECT (2U)
/* Clock pre divider for sai1 clock source */
#define DEMO_SAI1_CLOCK_SOURCE_PRE_DIVIDER (0U)
/* Clock divider for sai1 clock source */
#define DEMO_SAI1_CLOCK_SOURCE_DIVIDER (63U)
/* Get frequency of sai1 clock */
#define DEMO_SAI_CLK_FREQ   (CLOCK_GetFreq(kCLOCK_AudioPllClk) / (DEMO_SAI1_CLOCK_SOURCE_DIVIDER + 1U) / (DEMO_SAI1_CLOCK_SOURCE_PRE_DIVIDER + 1U))

 

What are the requirements for the SAI CLK Frequency when used for MQS (specifically for 16KHz sample rate)?

What I've found on my board - we have GPIO_B0_00 (as an MQS Audio Out pin) connected to an audio amp & speaker, and it seeems that instead of the above (0 and 63) divider values, I have to use any one of the following predivider & divider combos to get sound right:

(42 & 2, 33 & 2, 25 & 2, etc)...

When I say sound right - the pitch/tone matches what I see in Matlab or Audacity BUT the volume is very quiet.

If I use an off pitch / horrible pitch divider/predivider combo, the volume will get louder and be more audible, but the pitch / sound itself is awful.

 

Is there an explanation somewhere behind properly setting the dividers and how this affects pitch & volume?

 

Thanks

 

 

Labels (1)
Tags (2)
0 Kudos
1 Solution
1,926 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @variable_andrew ,

1  Could you explain why exactly these clock dividers were selected for the demo?

Answer: it is used to configure the SAI clock, which will be used to your SAI single.

 

2 What are the requirements for the SAI CLK Frequency when used for MQS (specifically for 16KHz sample rate)?

Answer: 

You can refer to my SAI post:

https://community.nxp.com/t5/i-MX-RT-Knowledge-Base/RT10xx-SAI-basic-and-SDCard-wave-file-play/ta-p/...

BCLK= master clock/(TCR2[DIV]+1)*2

Sample rate = Bitclockfreq /(bitwidth*channel)

Your SAI module clock master >= master clock.

That's why you configure the SAI clock.

 

3. What I've found on my board - we have GPIO_B0_00 (as an MQS Audio Out pin) connected to an audio amp & speaker,

Answer: do you connect to the driver circuit?

You can refer to this post:

   https://community.nxp.com/t5/i-MX-RT/How-to-use-MQS-on-trial/m-p/1154048

I share one video about the MQS play.

MQS hardware.jpg

 

You can use this type driver circuit, then connect to your speaker.

About the sai mqs code, please check the attachment.

 

Wish it helps you!

Best Regards,

Kerry

View solution in original post

4 Replies
1,927 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @variable_andrew ,

1  Could you explain why exactly these clock dividers were selected for the demo?

Answer: it is used to configure the SAI clock, which will be used to your SAI single.

 

2 What are the requirements for the SAI CLK Frequency when used for MQS (specifically for 16KHz sample rate)?

Answer: 

You can refer to my SAI post:

https://community.nxp.com/t5/i-MX-RT-Knowledge-Base/RT10xx-SAI-basic-and-SDCard-wave-file-play/ta-p/...

BCLK= master clock/(TCR2[DIV]+1)*2

Sample rate = Bitclockfreq /(bitwidth*channel)

Your SAI module clock master >= master clock.

That's why you configure the SAI clock.

 

3. What I've found on my board - we have GPIO_B0_00 (as an MQS Audio Out pin) connected to an audio amp & speaker,

Answer: do you connect to the driver circuit?

You can refer to this post:

   https://community.nxp.com/t5/i-MX-RT/How-to-use-MQS-on-trial/m-p/1154048

I share one video about the MQS play.

MQS hardware.jpg

 

You can use this type driver circuit, then connect to your speaker.

About the sai mqs code, please check the attachment.

 

Wish it helps you!

Best Regards,

Kerry

1,888 Views
variable_andrew
Senior Contributor I

1,2 - The sample rate has to be greater than or equal to, or it needs to be an exact multiple of the sample rate?

I'd assume the latter avoids some sort of audio artifact...

 

3.

Screen Shot 2021-11-03 at 2.53.53 PM.png

 

Not using a separate driver.

The above circuit (where pwm Audio Signal is the MQS pin) actually works - and plays sounds, just that we had to mess with the MQS frequency clock dividers to get there. (We also had to change R94/R95 for better volume).

Not sure I understand why you say in your other post that "RT EVK board still can't support the MQS directly" - I suppose this is because the pin isn't directly accessible (not a limitation of the RT device itself, but rather the EVK)?

0 Kudos
1,875 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @variable_andrew ,

  Next time, please create the RT question in the RT area, thanks:

https://community.nxp.com/t5/i-MX-RT/bd-p/imxrt

  My comment that : "RT EVK board still can't support the MQS directly"

  It means, you can't connect the MQS pin directly to the buzzer, you need the driver circuit.

 Eg, this post:

https://community.nxp.com/t5/i-MX-Processors/RT1064-MQS-Driver-Circuitary/m-p/1367103#M182667

Your side also add the amp, it is correct.

If you still have issues, please create the RT question in the correct community ,thanks.

Best Regards,

kerry

1,871 Views
variable_andrew
Senior Contributor I

Got it - and will try n remember - I thought we fell under i.MX

 

0 Kudos