Generating audio with the DAC on MQX

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

Generating audio with the DAC on MQX

411 Views
ryanlush
Contributor IV

I am trying to generate audio with the DAC in MQX. The problem I am having is getting the sampling rate precise. I have the audio coming out, just not at the required 8192 samples/sec sampling rate. It looks to me like the "right" way to do this would be using DMA with a timer to trigger the sample but I can't find an example on how to do this? Is there an easier way to do this, knowing that I am stuck with MQX?

0 Kudos
1 Reply

264 Views
dereksnell
NXP Employee
NXP Employee

Hi Ryan,

 

Yes, the best option for this is to use hardware triggering for the DAC, triggered by a hardware timer so you get the exact sampling rate.  Since you already have the DAC output working with software trigger, it won’t be difficult to setup for hardware triggering.  You need to setup a timer for the sampling rate.  Typically the PDB timer is used in Kinetis to trigger the DAC.  Then configure the DAC for hardware trigger using the DACx_C0[DACTRGSEL] bit, or DAC_TRIGER_MODE in the MQX DAC driver. 

 

I’m not aware of an MQX example that uses the DAC in hardware trigger mode like this.  There are some MQX DAC audio appnotes written for the KwikStik board.  But these use software trigger, writing to the DAC registers in the FTM timer ISR.  There is an example in the Kinetis Software Development Kit (KSDK), which you could use as a reference.  This is an example for the PDB driver, and is located in the driver examples folder, like \SDK_2.0\boards\frdmk64f\driver_examples\pdb\dac_trigger.

 

Best regards

0 Kudos