Incorrect samplerate from RTL-SDR

Joris van Rantwijk joris at
Sun Jan 5 14:54:19 UTC 2014


Let me first say that librtlsdr is great. It is a fantastic way for me
to learn about SDR. Also, the library seems very well designed, easy to
use, and at a convenient level of abstraction. Many thanks for putting
this together!

I'm using librtlsdr to make a wideband FM receiver in C++. Perhaps more
about that later.

I noticed the following problem:
When I configure a sample rate lower than 1 MS/s, I often get a very
different sample rate then what I ask for. The library reports back the
same sample rate that I asked (via rtlsdr_get_sample_rate), but the
actual sample rate does not match at all.

For example, asking 900 kS/s results in ~ 290 kS/s.
Asking 800 kS/s gives ~ 285 kS/s.
Asking 600 kS/s gives ~ 255 kS/s.
Asking 400 kS/s gives ~ 1700 kS/s.
Asking 300 kS/s gives 300 kS/s.

I know the real samplerate from looking at the amount of data I get out
of the library in a given amount of time. I have also looked at the
FFT spectrum of the data and this confirms my estimate of the actual
sample rate (this eliminates the hypothesis that RTL is sampling at
configured rate but losing some of the data packets).

After diving into librtlsdr.c, I found that the pattern of configured
vs real sample rate can be explained by assuming a specific bit error in
the configuration word rsamp_ratio. Bit 28 of the word is forced equal
to bit 27.

It is as if somebody is doing
  rsamp_ratio = (rsamp_ratio  & 0x0fffffff) |
                ((rsamp_ratio & 0x08000000) << 1);
after the configuration is sent out via USB but before it is applied by
the RTL chip.

I have a Terratec Cinergy Tstick RC rev3, USB ID 0ccd:00d3.
The RTL-SDR library reports:
  Realtek, RTL2838UHIDIR, SN: 00000001
  Using device 0: Terratec Cinergy T Stick RC (Rev.3)
  Found Elonics E4000 tuner

Does this ring any bells for people who understand the RTL chip?
Is it caused by the difference between RTL2832 vs RTL2838?

I have seen other reports on the mailing list, saying that sample rates
between 300 kS/s and 900 kS/s don't work. If this applies to all RTL
devices, then maybe it should be documented and the library can return
an error code for such sample rates. Otherwise people will keep walking
into this trap.

Kind regards,
Joris van Rantwijk.

More information about the osmocom-sdr mailing list