Tuner serial interface

Posted by: caederus

Tuner serial interface - 02/07/2002 03:39

Is there a definitive description of the serial interface to the tuner module?
From what I can see of past discussions, information is very sketchy. Could
Patrick or Hugo oblige with a complete list?

Here's what I have gleaned from past posts:

http://empeg.comms.net/php/showthreaded.php?Cat=&Board=hackers_prog&Number=76423
Responses from the Tuner always always always begin with 0x01

http://empeg.comms.net/php/showthreaded.php?Cat=&Board=hackers_prog&Number=76416
...the 3 byte init string Hugo originally sent me of 0x01, 0x00, 0x01

http://empeg.comms.net/php/showthreaded.php?Cat=&Board=empeg_tech&Number=95104
There are 2 parameters which define when the tuner will send a stalk command
0x01 0x08 <fuzz> <loops>

http://empeg.comms.net/php/showthreaded.php?Cat=&Board=empeg_tech&Number=37787
0x02 - indicates a command from the stalk interface
0x00 / 0x01 - indicates that the shift switch is off / on
ADC1 first sample read from the remote
ADC2 second sample read from the remote

http://empeg.comms.net/php/showthreaded.php?Cat=&Board=hackers_prog&Number=81713
To read the knob, send "0x01 0x09", and the Tuner will reply with
"0x01 0x09 0x0y 0x(9+y)", where "y" is the dial setting.
Posted by: tonyc

Re: Tuner serial interface - 02/07/2002 05:50

Is this helpful?
Posted by: caederus

Re: Tuner serial interface - 02/07/2002 06:18

I was more interested in the tuner side of things; that article
concentrates on the wired remote data.

Perhaps the serial interface has little to do with the radio operation.
From the kernel source, it seems that all the tuning, signal strength and
RDS stuff is done by the fiendishly complex SAA7705H DSP. From the block
diagram on the SAA7705H data sheet, it looks as if some dumb front-end
circuitry just hands over a chunk of spectrum, in which case the serial
port may be used for nothing more than switching the receiver, LED and
antenna on and off.
Posted by: number6

Re: Tuner serial interface - 02/07/2002 21:57

You pretty much have worked it out.

Yes, the Tuner interface is very low-level and the tuner module does little else than accept I2C commands to read and write certain registers on the Tuner module in the tuner.

The 'smarts' are all on the Empeg itself, either in the DSP (where the RDS signal is processed), or in the kernel and/or player software (for the tuning, user interface etc).

Posted by: altman

Re: Tuner serial interface - 08/07/2002 06:05

Not quite; the tuner module does *all* the tuning (front end, IF mix, demod etc etc). The DSP just does baseband signal processing (weak signal processing, inteference supression, etc), RDS extraction and FM demultiplex.

The tuner module itself is handed a frequency and various other settings and gives you the demodulated AF L+R/L-R/RDS signal over one wire and an analogue indication of signal strength over another.

There is an I2C eeprom in the tuner module which contains calibration values which are used (with interpolation) to calibrate signal strength indications over the entire tuning range.

Hugo
Posted by: caederus

Re: Tuner serial interface - 08/07/2002 06:25

I presume the tuner module is ``handed a frequency and various other
settings'' over the serial port? If so, any chance you could list all
the commands, and what the settings are?

TIA
Posted by: mlord

Re: Tuner serial interface - 08/07/2002 15:13

If you cannot get a list of them, many are easy enough to reverse-engineer by enabling "trace_tuner=1" in Hijack, and then watching the serial console output while trying various Tuner operations.

Cheers
Posted by: altman

Re: Tuner serial interface - 08/07/2002 16:08

I've not got a document of the commands, but you will also need the UFC1384 datasheet from Microtune as this documents the calibration and interpolation values. If anyone really, really, wants the tuner commands I'll try and find time to write them down from the PIC source...

Hugo
Posted by: altman

Re: Tuner serial interface - 08/07/2002 16:10

Correction on the stalk response: the last byte is a checksum, so is (shift reading+adc reading) and not first/second ADC reads. Before we send a stalk response from the tuner we wait until the ADC read has settled for a certain number of ADC reads within a certain amount of fuzz (+/- range)

Hugo
Posted by: mlord

Re: Tuner serial interface - 08/07/2002 18:57

Methinks that might be useful information to the community, and t'would be a shame were it lost forever.

Thanks Hugo!
Posted by: altman

Re: Tuner serial interface - 11/07/2002 03:10

Ok, the basics: 19200bps, 8n1

Commands of the form:

0x01 <command> [<command data>]

Commands are answered with replies of the form
0x01 <command> <result> <command+result>

There's no checksum on commands. There are 2 special commands, 0xf0 and 0xf1 (single bytes, not prefixed with 0x01) which tune to frequency A and B respectively - this is for quick switching to do RDS updates.

Other replies from the tuner are:

0x02 <shift> <key> <shift+key>
Stalk response. Shift indicates the shift state of the track skip part (which can be pushed in, binary 0/1) and key indicates the adc value.

0x03 0x01 0x00 0x01
Overcurrent indication on antenna supply. Current limit exceeded, foldback in operation. This indicates a likely short on the antenna output (load <25ohms attached).

command 0: tuner enumerate
1 parameter (0=tuner off/led off, 1=tuner on/led on).
If turned on, result is the tuner id (0x03=am/fm module rev 1) otherwise it's 0.

command 1:
Full tuner setup
8 parameters. Full tuner setup sent to tuner chip (8 bytes).
Result 0

command 2:
Full tuner setup and tuneto
8 parameters. Does tuner setup then resends first 3 bytes with bit 7 of 3rd byte cleared (unmute audio). Saves frequency as frequency A.
Result 0

command 3:
Tuneto
3 parameters sent as first 3 bytes to tuner. Saves as frequency A.
Result 0

command 4:
read eeprom
1 parameter (address in i2c eeprom to read. i2c eeprom is inside the canned module and contains antenna calibration values which are individually calibrated & stored).
Result is the read byte

command 5:
antenna power on/off
1 parameter: 0=antenna down, 1=antenna up
Result 0

command 6:
AM/FM switch direct control
1 parameter, 0=fm/1=am (I think). Usually, tuneto sets the analogue switch automatically so that the FM-MPX/AM-AF wire to the empeg carries the appropriate tuner output; this allows it to be overridden just in case you want to get freaky with the output.
Result 0

command 7:
Force a stalk poll
0 parameters
NO REPLY: well, no normal format reply. You will get a stalk response.

command 8:
set stalk fuzz/stable time
2 parameters: fuzz then stabletime. Fuzz defines the range within which the stalk adc readings have to stay within (eg 2 will mean that the reading has to wobble <= +/- 2 from the last ADC read) for <stable time> loops before it's classified as stable enough to send to the host. Default is 2/100.
Result 0

command 9:
read tuner module ID
0 parameters
Result is tuner module ID (on rotary dial)

command 10:
read IF counter from tuner
0 parameters
Result is IF counter byte read from tuner module.

command 11:
LED mode
1 parameter, on/off. If LED mode is set, the LED on the tuner is PWM'ed with relative signal strength - brighter=better signal. This does not affect any other tuner operation, it's just an installation debug tool.

command 12:
set frequency B
3 parameters, 3 bytes to send to tuner when 0xf1 command is received.
Result 0

command 13: (patrick's tuner only, version 0x28 onwards)
set outputs
1 parameter: low 2 bits control the 2 user output ports
Result 0

command 14: (patrick's tuner only, version 0x28 onwards)
read inputs
0 parameters
Result is state of 4 user inputs in bits 0-3

command 255:
read version
0 parameters
Result is tuner version number. I believe production units are 0x27 (v2.7)

...that's about the size of it! I can't find my open tuner module, but the 8 byte setups are very much like the TEA6840 ISTR, though the chip is a later model. You really want the UFC1384 module datasheet from Temic.

Hugo
Posted by: Shonky

Re: Tuner serial interface - 11/07/2002 05:51

Perhaps someone could paste this into the FAQ or Developer Guide over at Riocar.org? Valuable bit of info there.

Also I see where you have been adding the codes for Patrick's DIY tuner with "extra stuff". Cool.
Posted by: tfabris

Re: Tuner serial interface - 11/07/2002 10:31

Agreed. Someone PLEASE put that in the developer section of riocar.org.

Isn't some of it already in there, though?
Posted by: Shonky

Re: Tuner serial interface - 11/07/2002 17:00

Ummm don't think so. There is a large section on stalk commands in the Main -> Mk2 Hardware section of the developer guide but it really glosses over the actual commands to tuner (mentions only the 02 command) and concentrates on the stalk stuff
Posted by: caederus

Re: Tuner serial interface - 17/07/2002 12:28

That's exactly what I needed, thanks!

Now to find the UFC1384 data sheet...
Posted by: Shonky

Re: Tuner serial interface - 17/07/2002 18:09

I thought they were made by microtune... although that may be the complete module itself rather than the main IC (which might be made by Temic).

http://www.microtune.com/products/1384_Series.html

I have attached the Microtune .PDF brochure but it's not what you're after
Posted by: Shonky

Re: Tuner serial interface - 17/07/2002 18:12

OK,

Temic is owned by Microtune so that makes sense...
Posted by: altman

Re: Tuner serial interface - 18/07/2002 02:48

Come to think of it, the datasheet for the tuner wasn't under NDA, so I'll save you some hassle:

http://utter.chaos.org.uk/~altman/temic_7660.pdf

(though if someone else wants to mirror/host this I'm happy, it may not stay there forever)

Hugo
Posted by: smu

Re: Tuner serial interface - 18/07/2002 04:58

This (as well as the DSP docu) is now in the downloads section of riocar.org, under add-ons/documentation for now.

cu,
sven
Posted by: mlord

Re: Tuner serial interface - 23/08/2013 10:44

Updated link for the temic_7660.pdf datasheet:
http://riocar.org/download.php?op=getit&lid=43