• Status Closed
  • Percent Complete
  • Task Type Patches
  • Category FM Tuner
  • Assigned To No-one
  • Operating System Iriver H300 series
  • Severity Low
  • Priority Very Low
  • Reported Version
  • Due in Version Undecided
  • Due Date Undecided
  • Votes
  • Private
Attached to Project: Rockbox
Opened by Matze88m - 2006-05-27
Last edited by bluebrother - 2011-06-04

FS#5448 - FM Radio TEA5767: New Features

I spent a few hours on making FM Radio of my H300 fitting my optionion :)
This patch is coded not with much attention to the coding rules, so no use of langfiles and some other not very fine things.

Range from 1MHz to nearly 134MHz. Frequencyrange is selectable in radio menu.
Frequencysteps: 8192, 32768, 50000, 100000, 500000 HZ for fast and for fine tuning (8192Hz is minimum step for tea5767)
Highside/Lowsideinjection can be chosen via menu to remove noise of unwanted stations… mostly works for me :) (code works but effect is not always there)

And finally the thing i coded first, some weeks ago and which is VERY unstable (not really unstable, but not really good working):
signalstrength indicator with “Softwaremute”. When strength drops below 1, volume is decreased by 0/10/15/20, if it raises above 2 volume is increased same value. Set it to 0 for off. I recommend the Off-setting because it doesnt really work and consumes some CPU power (→+ more noise because you hear every cpuactivity in the radio). The signalstrengthindicator is then also off.

Why did I code this?
a) the german “CB-Funk” around 27MHz works fine :)
b) flight-radio, 108-133MHz is fine also ^^ Well, it is AM so you HAVE noise while listening, but it is okay.

Closed by  bluebrother
2011-06-04 20:48
Reason for closing:  Out of Date
Additional comments about closing:   Warning: Undefined array key "typography" in /home/rockbox/flyspray/plugins/dokuwiki/inc/parserutils.php on line 371 Warning: Undefined array key "camelcase" in /home/rockbox/flyspray/plugins/dokuwiki/inc/parserutils.php on line 407

this is not going to get in in that state. Plus, no updates since years.

I tried to check the signal strength on an X5 (D&A202 behaves much like the TEA5767)
and it seems to be pretty much constant (per PLL setting) although the mono/stereo flag changes as I plug/unplug the antenna (i.e., headphones :)

— manual diff — edit apps/debug_menu.c and add to dbg_fm_radio():

#include “tuner.h” … bool fm_detected
+unsigned long regs;
… lcd_puts(0, 0, buf);
+regs = philips_get(RADIO_ALL);
+snprintf(buf, sizeof buf, “Tuner registers: %08lx”, regs);
+lcd_puts(0, 1, buf);

Although you might have asked in the board or opened a new patch thread (doesnt have anything todo with tea5767), I can tell you of a problem with 5767:
ADC value was only updated after some sending to the tunerchip… That is why I set force mono to false every time before the reading. Another aspect of a not-very-fine thing in the code :) But I think for the one who needs this indicator, it is a really good thing. Perhaps you could (or I could?) add an “everytimethere” Signalindicator with regularly updates only when the backlight is on (this would cause problems with the remote… but that is another point. as i dont have a remote i can’t take this into account) to reduce noise and cpu power consumed. Maybe we could constantly put the cpu into idle mode while radio is on and backlight is off? That would further remove noise. And it should decrease power drain a bit. We could even put the whole thing into a “sleep”state after 1 minute of backlight off so rockbox does NOTHING than checking for keys about once a second… Shouldnt this increase battery life drastically? (→sleep mode for Ram, sleep mode for lcd controller, maybe even shutdown the hddcontroller?) It should be possible to listen to radio with about only 50mA (15 for tea5767, another 15 for soundmixer and amplifier and some… well… small amounts for cpu and powercontroller and so on), that would be 1300/50 → >25 hours with original battery.

Well,I’m dreaming^^ sry

The patch is incomplete - although it applies fine (except a whitespace change that was rejected for some reason) compilation fails on tuner_philips.c with the following error:

tuner_philips.c: In function `philips_set’:
tuner_philips.c:57: error: `RADIO_HIGHSIDEINJECTION’ undeclared (first use in this function)
tuner_philips.c:57: error: (Each undeclared identifier is reported only once
tuner_philips.c:57: error: for each function it appears in.)
tuner_philips.c: In function `philips_get’:
tuner_philips.c:144: error: `RADIO_STRENGTH’ undeclared (first use in this function)

I’m guessing this would also work on h100 and ondio as well, since they use the exact same chip?

Oh sorry, i forgot to include the header file (firmware/export/tuner.h) into the patch. here is a NEW complete patch (you only have to apply this one)

Lamed commented on 2006-09-18 13:47

I have had an access to a military radio for a while but I couldn’t get anything under 62~ mhz.

Hi, Matthias, it was very encouraging to read about your work with the radio. I live in Ukraine and we have lots of FM and other radios that work with lower frequencies than my H320 permits. I have tried to aplly your patch to the current cvs build and it gives me lots of Hunk failures. I assume that the patch is just not compatible with the most recent build. WOULD YOU BE SO KIND to produce a new patch so I could use it here? I would be very, very thankful.
Danke shon.

Ingwar, what frequencies are you talking about? We have a region setting which is intended to set settings like frequency bounaries. From the research I did when implementing this setting I haven’t found any specific values for Ukraine. IMO it would be a lot better to add a task telling the correct values so that setting can get extended instead of relying on a patch that allows tuning into non-radio frequencies which in turn will most probably never get into Rockbox.

If you intend to tune into non-radio frequencies that’s of course a different thing.

Dominik, in Ukraine we have commercial FM radios in 64-108.7 FM. I would be very happy to get that as a region setting. Scanning step of 0.05MHz (Europe region) is fine. Non-commercial radio frequencies would be a nice patch to have for my private use as a radio amator. Can you help with any/all of that? Thanks for your time.

sorry, i dont have the time for doing a new patch… But here is a short explanation what to do manually:

Line 100-110:
Edit the preset u want to use later. DEEMPH_50 is correct for u. You can change Min-Freq, Max Freq and Freq_step. (All in Hz)
The Bandlimit is only used for searching the next station and is not relevant for the Frequencylimits used by rockbox (for now, maybe some day a new patch will implement reading the BandLimitReached-Flag of the tunerchip)

Thats all :)
Good luck,


Matze, thanks a lot! that really helped! Although my knowledge of programming is kind of old (BASIC) I figured out how to get my own radio modified build. Thanks for your help. I can tune into 1-134MHz. There are a couple of things I’d like to improve.
1) Although I have changed /* Europe*/ to /* Ukraine */ in the radio.c when operating H320 tuner it still says Europe mode on the screen. How do I change that?
2) I have picked up a few stations on the 64-88MHz FM dial and was able to positively identify them using my other digital PLL radio. But the station that I need to pick up is looud and clear on that PLL FM radio but does not show up on the H320. There’s just white noise. The signal is too weak (probably)? Although looking at I could tell that the sensitivity of the H320 tuner is pretty good. Has selectivity anything to do with it? What can be done?
I appreciate your time and help very much

No Problem for that :)

The /* Europe */ is just a comment in the source. You have a LANG_EUROPE or something like this in the same line, thats the constant used for language. in your english.lang or whatever you’re using u can change the specific one to your wishes.

The tuner itself does only work correct for upper frequencies, maybe down to 60-70MHz. I never got it receiving anything lower than that (although i wrote about CB-Funk (27MHz) in my first post. I dont know why i wrote that, now :) ) Maybe your wanted station is lower?

Tune a bit around, you never get it tuned? Maybe lower the frequency step size… that can be as low as 8192.

MikeS commented on 2007-01-10 21:04

A lot can be done. I’ve got a patch that improves reception and makes station scanning rock solid but my x5 joystick broke when doing final tuning so haven’t been able to finish up on that. The biggest reception improvement was on the x5 by far but it was also the weakest prior to my changes. The H120 benefitted greatly as well esp. for scanning and auto preset mode. I hope Cowon gets the x5 back in order soon so I may finish and commit my code. Addresses as well B#6390 - Rumbling Noise in the Main FM Window.

BTW: On the x5 putting the CPU in idle mode is a _cause_ of a lot of noise. I may look into allowing slowing of the i2c drivers when code requests as the only real noise left was when reading out the Stereo/Mono display which must be polled for.

I just had a look in the data sheet. From what I’m reading:
- you can’t tune lower than 76 MHz because of the mixer. See page 7, section 7.2 and others. Maybe you could trick that by using a different VCO frequency.
- you can write anything to the PLL you want, even 1MHz. If it’s outside of the range of the mixer you’ll get white noise.

Apart from that, the name displayed in the setting is in the lang file, not in the source itself.

To Dominik: I was able to pick up valid FM stations on 73.65MHZ and 69.0MHz which is pretty amazing if it is outside of the mixer’s range! :-) I don’t know how it does it but it does it.
To Michael Sevakis: Could you share with me some of those steps on improving selectability/reception? I am not a programmer but being an engineer in my blood I hope I can figure it out :-) And God bless all of you guys working on the Rockbox, what an amazing gadget my H320 now is!

To Matze, thanks, I’ll try to lower the step… The station that I need is on 67.3MHz which should be reachable, I hope. I have also picked a couple of FM stations on as low as 34.65MHz and as high as 133.70MHz (stereo!). I can’t confirm whether these are valid stations or some phantom product of the internals of the tea5767… No CB so far :-D

MikeS commented on 2007-01-11 10:27

I’ll do better. I’ll give you the patch as it was at the time. Don’t know if it will still apply cleanly.

For scanning and tuning:
*check high/low side injection for best signal strength
Next step for scanning:
*check tuned status, ADC level and IF counter, if in proper ranges, add station

Note that my algorithm deviates from the tea5767 app notes but gave me the same results or better. The scanning is better than the original firmware which misses a good number of stong local stations. My FM region is US/Canada BTW.

Added app notes to datasheets page.

EDIT Again: Cleaner link :)

MikeS: your patch seems to be really cool :) I tried around myself with high/lowside injection, but not automatically. I got noise erros when frequently reading the tuner over I2C bus… (→signal strength indicator)

Thank you! I will have a look at it in the next days

MikeS commented on 2007-01-31 09:06

Matthias: Did you do any testing? Don’t really know if it will help things out in the extended range outside the chip’s spec.

petur commented on 2007-08-05 00:41


i was told that this patch “Expands the frequency range that can be tuned into and allows for changing the tuning step.” if this is the case or the main thing the patch does, i think itsnot needed and can be closes.

I think it if it actually works, it’s one of those things that would make Rockbox exceed what the OF can do.

It’s not useful for everyone, so it should probably be in a separate screen, or enabled by a setting somewhere, but it doesn’t seem completely useless. It might be outdated now though?

I’d like to have this feature, personally…but done right, of course.


Available keyboard shortcuts


Task Details

Task Editing