i.MX93 ADC – Continuous / Scan Mode for Stable 48 kHz Sampling

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

i.MX93 ADC – Continuous / Scan Mode for Stable 48 kHz Sampling

549 Views
moezmefteh
Contributor I

Hello,

I’m working on an ADC-based audio capture use case on i.MX93 and would like to confirm whether continuous / scan mode is supported in the ADC driver, and whether our analysis is correct.

Goal:
Capture ADC samples at a stable 48 kHz to feed an audio processing pipeline.

Current situation
1) One-shot mode
Using imx93_adc_read_channel_conversion() the effective sampling rate is limited by CPU scheduling and context switches.
In practice, we only reach ~14 kHz, which is not suitable for audio.

2) IIO triggered buffer + hrtimer
We switched to an IIO triggered buffer with a kernel hrtimer trigger at 48 kHz (20.83 µs):

  • hrtimer trigger @ 48 kHz
  • trigger handler polls EOC
  • samples pushed to IIO kfifo
  • userspace reads /dev/iio:deviceX

Although the hrtimer is configured at 48 kHz, the effective capture rate is unstable (~47.xx kHz).

Our understanding is that this happens because:

  • each trigger still starts a one-shot conversion
  • conversion is retriggered every period
  • software overhead and context switches occasionally miss deadlines

So the sampling rate is not strictly deterministic.

Hardware / RM analysis
According to the i.MX93 Reference Manual:

  • ADC supports up to 1 MS/s
  • Normal mode supports:
    • One-shot
    • Scan (continuous) conversions

This suggests that a continuous / scan mode could provide a stable 48 kHz rate, where:

  • ADC is started once
  • samples are generated continuously
  • software only consumes data from a buffer (no per-sample retrigger)

Questions

  1. Is scan / continuous mode currently supported in the i.MX93 Linux ADC driver?
  2. If not supported:
  • Is continuous / scan mode the recommended approach for stable audio-rate sampling (e.g. 48 kHz)?
  • Are there any reference patches, examples, or guidelines from NXP?

Any feedback or confirmation would be very helpful.

Thanks in advance.

0 Kudos
Reply
1 Reply

436 Views
JosephAtNXP
NXP TechSupport
NXP TechSupport

Hi,

Thank you for your interest in NXP Semiconductor products,

SW team confirmed that Linux driver doesn’t support Scan mode. However you may refer to example code on MCU SDK. You can try to run it on i.MX93 directly, but it also can be used for reference with same IP.

It's located mcuxsdk-examples/driver_examples/sar_adc/sample_rate_measurement/sample_rate_measurement.c 

Regards,

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2354145%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3Ei.MX93%20ADC%20%E2%80%93%20Continuous%20%2F%20Scan%20Mode%20for%20Stable%2048%20kHz%20Sampling%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2354145%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3EI%E2%80%99m%20working%20on%20an%20ADC-based%20audio%20capture%20use%20case%20on%20i.MX93%20and%20would%20like%20to%20confirm%20whether%20continuous%20%2F%20scan%20mode%20is%20supported%20in%20the%20ADC%20driver%2C%20and%20whether%20our%20analysis%20is%20correct.%3C%2FP%3E%3CP%3E%3CSTRONG%3EGoal%3A%3C%2FSTRONG%3E%3CBR%20%2F%3ECapture%20ADC%20samples%20at%20a%20stable%2048%20kHz%20to%20feed%20an%20audio%20processing%20pipeline.%3C%2FP%3E%3CP%3E%3CSTRONG%3ECurrent%20situation%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3E1)%20One-shot%20mode%3C%2FSTRONG%3E%3CBR%20%2F%3EUsing%20imx93_adc_read_channel_conversion()%26nbsp%3Bthe%20effective%20sampling%20rate%20is%20limited%20by%20CPU%20scheduling%20and%20context%20switches.%3CBR%20%2F%3EIn%20practice%2C%20we%20only%20reach%20~14%20kHz%2C%20which%20is%20not%20suitable%20for%20audio.%3C%2FP%3E%3CP%3E%3CSTRONG%3E2)%20IIO%20triggered%20buffer%20%2B%20hrtimer%3C%2FSTRONG%3E%3CBR%20%2F%3EWe%20switched%20to%20an%20IIO%20triggered%20buffer%20with%20a%20kernel%20hrtimer%20trigger%20at%2048%20kHz%20(20.83%20%C2%B5s)%3A%3C%2FP%3E%3CUL%3E%3CLI%3Ehrtimer%20trigger%20%40%2048%20kHz%3C%2FLI%3E%3CLI%3Etrigger%20handler%20polls%20EOC%3C%2FLI%3E%3CLI%3Esamples%20pushed%20to%20IIO%20kfifo%3C%2FLI%3E%3CLI%3Euserspace%20reads%20%2Fdev%2Fiio%3AdeviceX%3C%2FLI%3E%3C%2FUL%3E%3CP%3EAlthough%20the%20hrtimer%20is%20configured%20at%2048%20kHz%2C%20the%20effective%20capture%20rate%20is%20unstable%20(~47.xx%20kHz).%3C%2FP%3E%3CP%3E%3CSTRONG%3EOur%20understanding%20is%20that%20this%20happens%20because%3A%3C%2FSTRONG%3E%3C%2FP%3E%3CUL%3E%3CLI%3Eeach%20trigger%20still%20starts%20a%20one-shot%20conversion%3C%2FLI%3E%3CLI%3Econversion%20is%20retriggered%20every%20period%3C%2FLI%3E%3CLI%3Esoftware%20overhead%20and%20context%20switches%20occasionally%20miss%20deadlines%3C%2FLI%3E%3C%2FUL%3E%3CP%3ESo%20the%20sampling%20rate%20is%20not%20strictly%20deterministic.%3C%2FP%3E%3CP%3E%3CSTRONG%3EHardware%20%2F%20RM%20analysis%3C%2FSTRONG%3E%3CBR%20%2F%3EAccording%20to%20the%20i.MX93%20Reference%20Manual%3A%3C%2FP%3E%3CUL%3E%3CLI%3EADC%20supports%20up%20to%201%20MS%2Fs%3C%2FLI%3E%3CLI%3ENormal%20mode%20supports%3A%3CUL%3E%3CLI%3EOne-shot%3C%2FLI%3E%3CLI%3EScan%20(continuous)%20conversions%3C%2FLI%3E%3C%2FUL%3E%3C%2FLI%3E%3C%2FUL%3E%3CP%3EThis%20suggests%20that%20a%20continuous%20%2F%20scan%20mode%20could%20provide%20a%20stable%2048%20kHz%20rate%2C%20where%3A%3C%2FP%3E%3CUL%3E%3CLI%3EADC%20is%20started%20once%3C%2FLI%3E%3CLI%3Esamples%20are%20generated%20continuously%3C%2FLI%3E%3CLI%3Esoftware%20only%20consumes%20data%20from%20a%20buffer%20(no%20per-sample%20retrigger)%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%3CSTRONG%3EQuestions%3C%2FSTRONG%3E%3C%2FP%3E%3COL%3E%3CLI%3EIs%20scan%20%2F%20continuous%20mode%20currently%20supported%20in%20the%20i.MX93%20Linux%20ADC%20driver%3F%3C%2FLI%3E%3CLI%3EIf%20not%20supported%3A%3C%2FLI%3E%3C%2FOL%3E%3CUL%3E%3CLI%3EIs%20continuous%20%2F%20scan%20mode%20the%20recommended%20approach%20for%20stable%20audio-rate%20sampling%20(e.g.%2048%20kHz)%3F%3C%2FLI%3E%3CLI%3EAre%20there%20any%20reference%20patches%2C%20examples%2C%20or%20guidelines%20from%20NXP%3F%3C%2FLI%3E%3C%2FUL%3E%3CP%3EAny%20feedback%20or%20confirmation%20would%20be%20very%20helpful.%3C%2FP%3E%3CP%3EThanks%20in%20advance.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2355413%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20i.MX93%20ADC%20%E2%80%93%20Continuous%20%2F%20Scan%20Mode%20for%20Stable%2048%20kHz%20Sampling%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2355413%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%2C%3C%2FP%3E%0A%3CP%3EThank%20you%20for%20your%20interest%20in%20NXP%20Semiconductor%20products%2C%3C%2FP%3E%0A%3CP%3ESW%20team%20confirmed%20that%20L%3CSPAN%3Einux%20driver%20doesn%E2%80%99t%20support%20Scan%20mode.%20However%20you%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Emay%20refer%20to%20example%20code%20on%20MCU%20SDK.%20You%20can%20try%20to%20run%20it%20on%20i.MX93%20directly%2C%20but%20it%20also%20can%20be%20used%20for%20reference%20with%20same%20IP.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EIt's%20located%20mcuxsdk-examples%2Fdriver_examples%2Fsar_adc%2Fsample_rate_measurement%2Fsample_rate_measurement.c%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3ERegards%2C%3C%2FP%3E%0A%3CP%3E%3CLI-WRAPPER%3E%3C%2FLI-WRAPPER%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E