PROGRAMMING AN FM-AM RADIO TUNER USING THE LC72131 PLL IC



Radio receivers made with LC72131 IC, and other members of this family, were frequently used in many Music systems, portable Radio - Cassette Players etc. devices in the 90s and 2000s. Thanks to the PLL frequency adjustment technique created using these ICs, it has been possible to make radio receivers that work stably.

In this post, I will try to show how to tune an FM-AM receiver from such an old music system to the desired frequency (or station, as it can also be called).

PURPOSE

Tuning any FM-AM radio receiver using LC72131 IC, a member of the LC72xxx series PLL IC (integrated circuit) family produced by Sanyo, to the desired frequencies.

WHAT IS REQUIRED

A receiver circuit (Tuner stage) using LC72131 PLL IC.

Audio frequency amplifier to connect the receiver circuit to the audio output.

AT89S52 Microcontroller.

Text editor required to program the microcontroller in Assembly language (Ex: Notepad ++)

Asm51.exe .ASM to .HEX converter assembler program

ProgISP Ver1.72 software

USB ASP programmer

Datasheet of the PLL IC (LC72131 in our example) used in the tuner.

BASIC INFORMATION

What we will do, in the simplest terms, is to program this IC by taking the programming information in the datasheet of the PLL IC as reference, sending the information required to set the frequency (channel) we want to listen to via a microcontroller (PIC, ATMEL, ARDUINO etc.).

The programming technique explained here can be used for many different ICs in the LC72xxx series. Of course, provided that the Datasheet of the IC to be used is referenced. Because the hardware structures, pin connections etc. of the ICs in this series are different.

In summary, what we will do is:

TO SEND THE NECESSARY INFORMATION TO THE PLL IC WITH THE HELP OF A MICROCONTROLLER IN ORDER TO SET THE FREQUENCY (STATION) WE WANT TO LISTEN TO

LET'S START

As stated in the LC72131 IC datasheet, there are three operating modes:

IN1, IN2, OUT modes.

IN1 and IN2 modes are the modes where the necessary commands will be sent to set the IC to the desired frequency.

OUT mode is the mode that allows a register inside the IC to be read after the programming information is sent, which is used to test whether the PLL is locked to the desired frequency. We will not talk about this mode in this article. Because at this stage, we can program without using this mode.

Each mode has its own ADRESS.


The programming sequence will be as follows:                                                                                               

IN1 ADDRESS information (8 bits) + P0..P15 division information (16 bits) + Configuration information (8 bits)

IN2ADRESS information (8 bits) + 24 bit Configuration information BETWEEN IOC1....TEST2

In this way, sending a total of 64 bits (8 bytes) of information to the PLL IC in the form of serial transmission.

In order to perform these operations, we need to synchronously turn ON-OFF the pins used for programming of the LC72131 IC.

There are 4 pins in the LC72131 IC to be used for programming and reading the information in the internal register (OUT mode).



These are:

DI: Data input pin.

CLK: Clock (timing synchronous signal) pin

CE: Chip Enable pin

DO: Data Out (Reading internal register) pin.

We will send the necessary division information to the IC by turning these pins ON-OFF in the order specified in the datasheet.

PROGRAMMING FLOW


1. Before starting programming, set all pins OFF. IN1 mode information will be sent:

2. Send the first bit (B0 bit) of 8-bit IN1 ADDRESS (82h) to the DI pin.

3. Wait for 15 microseconds, then turn the CLK pin ON.

4. Keep the CLK pin ON for 15 microseconds.

5. Turn the CLK pin OFF.

6. Send the second bit of 8-bit ADDRESS information to the DI pin.

7. Repeat steps 3, 4 and 5.

8. Repeat steps 3, 4 and 5 until all bits of 8-bit ADDRESS information are sent.

9. When the last bit of ADDRESS information (A3 bit) is sent, turn the CE pin ON.

10. Send the programming bits between P0..P15 and the 8-bit configuration information using the DI pin, repeating steps 3, 4 and 5, respectively.

11. After all the bits in IN1 mode are sent (after the R3 bit is sent), turn the CE pin OFF.

12. Send the first bit (B0 bit) of the 8-bit IN2 ADDRESS (92h) information to the DI pin.

13. Repeat the steps from 3 to 8.

14. After all the bits in IN2 mode are sent (after the TEST2 bit is sent), turn the CE pin OFF.

The programming flow listed above is sent to the PLL IC by synchronizing the programming pins with each other thanks to the CLK signal. After this process, the PLL IC is locked to the desired frequency.

The programming timing (Serial Data Timing) square waveforms are shown in detail in the datasheet.


As seen in the timing table above, the minimum time between square wave periods is 0.75 microseconds. Any value above this is valid. We will use this period as 15 microseconds.

IN1 MODE AND PLL DIVIDE INFORMATION CALCULATION


Let's start the calculation by referring to the example in the picture above:

Let's say the radio station we want to listen to is broadcasting at 90.0 Mhz. The calculation we will do to listen to this station will be as follows:

FM RF Frequency = 90.0 Mhz
FM IF frequency = 10.7 Mhz
FM step frequency = 25 Khz (Frequency increase or decrease value)

According to these values, the Hexadecimal number (PLL division value) to be sent to the PLL is calculated as follows:

PLL division value = FM RF frequency + FM IF frequency / FM Step frequency /2

Let's put the values ​​in their places according to the formula above:

PLL division value = 90,000,000 Hz +10,700,000Hz/ 25,000Hz /2 = 2014 is found. The Hex equivalent of the number (2014)d will be =(07DE)h.

According to this calculation, the division value you will send to the PLL IC to listen to a radio station broadcasting at 90 MHz will be (07DE)h. This value is the value to be entered between P0..P15.
If you notice in the picture above (07DE)h number is entered from right to left. Accordingly, P15 is MSB (Most Significant Bit), P0 is LSB (Least Significant Bit). This order is important because PLL will not work if it is written in reverse.

This value will be sent to PLL IC in the order seen in the picture above.

After that, let's set SNS, DVS etc. 8 bit configuration information as 1 or 0 as explained in Datasheet:

DVS, SNS = Band (FM-AM) selection bits. For FM band DVS=1, SNS=* (1 or 0 does not matter) let's select 0.

CTE= 0 is selected. Since this parameter is related to Data out, it is out of our subject.

XS= 0 . Frequency selection of the crystal connected to PLL IC. If crystal frequency is 4.5Mhz,  if crystal frequency is 7.2Mhz, XS=1 is selected. Since the crystal frequency in our circuit is 7.2Mhz, 1 is selected.

R0...R3= Step frequency selection. Since we selected 25Khz in our example, R0=1,R1=1,R2=0,R3=0 is selected.

IN2 MODE SETTINGS

There are only three parameters that concern us in this article regarding IN2 mode. We will set the others to 0. These are:

IOC1,IOC2: Parameters used to determine the direction of the general purpose port pins of the LC72131 IC that can be used bidirectionally. If set to 0, the port pins are selected as Input, if set to 1, they are selected as Output. Since we will use this value as output in our circuit, we will select this value as 1.

IO1,IO2: General purpose port pins that can be used as Bidirectional (Bidirectional, Input-Output). These pins are used for the band selection (FM-AM), stereo-mono selection etc. of the radio receiver IC (LA1837 in our example). We will choose this value as 1 for our circuit.

B01...B04: These pins are also used as general purpose output ports to turn the necessary hardware ON-OFF. The number of ports can be used as many as the receiver circuit needs. It is not necessary to use all of them.

SENDING INFORMATION TO PLL IC

Now we have the information to be sent to the PLL IC to listen to the frequency we want. Now it is time for the microcontroller part of the job.
We connect the programming pins (DI, CE, CLK) of LC72131 to the ports of the microcontroller. In our example, the connection and the definition in the Assembly will be made as follows:


;------------------------------------------------------------------------
; TUNER PROGRAMMING DEFINITIONS
;------------------------------------------------------------------------
CE BIT P0.3 ; LC 72131 IC CE (CHIP ENABLE) pin-AT89S52 P0.3 pin 
DI BIT P0.4; LC72131 IC DI (DATA INPUT) pin-AT89S52 P0.4 pin 
CLK BIT P0.5; LC72131 IC CLK(CLOCK) pin-AT89S52 P0.5 pin

After defining the hardware pins, what we will do is to place the total 64 bit (8 byte) information series in 8 bit (1 byte) packages into the microcontroller's memory and send them to the PLL IC via serial transmission mode from the DI terminal when the time comes in the program flow. Now let's define our 1 byte memory areas:

ADDRESS DATA 50H ; ADDRESS information will be placed at memory address 50H

DIVIDE1 DATA 51H ; The first byte of the divide information (section P0...P7) will be placed at memory address 51H.

DIVIDE2 DATA 52H ; The second byte of the divide information (section P8...P15) will be placed at memory address 52H.

CONFIG DATA 53H ; Configuration bits (between SNS....R3) will be placed at memory address 53H.

IN2_BYT1 DATA 54H ; The first byte of IN2 mode (between IOC1..B04) will be placed at memory address 54H.

IN2_BYT2 DATA 55H ; The second byte of IN2 mode (between DNC..DZ1) will be placed at memory address 55H.

IN2_BYT3 DATA 56H ; The third byte of the IN2 mode (between GT0..TEST2) will be placed at memory address 56H.

Now let's place the information we obtained from the calculations into the microcontroller's memory:

;************************************************
;This procedure ensures that the Tuner starts at 90.0MHz when it is first powered on.
;************************************************
FMINIT:

MOV DIVIDE1, #0DEH ; LC72131 PLL Division information first byte, initial values ​​for 90 Mhz
MOV DIVIDE2, #07H ; LC72131 PLL Division information second byte
MOV CONFIG , #1AH ; LC72131 Other controls. DVS=1 FM /R0=1 (step number 50 khz)/XS=1 XTAL will be 7.2MHZ.
MOV IN2_BAYT1, #0ah ; ioc2 and io2 are set.
MOV IN2_BAYT2, #00H
MOV IN2_BAYT3, #10H ; ifs bit=1 is selected.

The next step is to send this information from the DI terminal to the PLL IC with the order and timing specified in the datasheet. For this, let's write a subroutine called SEND and the codes that set up and run the microcontroller's Timer for timing.

;***************************************************
; SENDING INFORMATION TO TUNER
;*********************************************

SEND:
;TIMER SETTINGS: Timer0, Mode2, will work as 8 bit auto reload. It will be set to overflow every 15 microseconds.

MOV TH0, #0F0H ; Timer will count from f0 to ff 15 times and will overflow and set TF0 flag to 1.

MOV TL0, #0f0H ; Counting will start from F0
SETB TR0 ; Start the Timer.

;--IN1 COMMANDS ARE SENT FROM HERE--

MOV ADRESS,#28H ; 82H IN1 ADDRESS information will be sent as MSB first as specified in the datasheet, so it is written in reverse as 28H.

MOV A,ADRESS ; 82H ADDRESS Information will be sent

CALL SEND1

SETB MODGITTI ; Mode information sent, set the flag bit

MOV A,DIVIDE1 ; LC72131 PLL Division information send first byte

CALL SEND1

MOV A,DIVIDE2 ; LC72131 PLL Division information send second byte

CALL SEND1

MOV A,53H ; LC72131 CONFIG byte send.

CALL SEND1

CLR CE ; IN1 mode information sending is over, IN2 is next.

;--IN2 COMMANDS ARE SENDING FROM HERE--

MOV ADRESS,#29H ; 92H IN2 ADDRESS information will be sent as MSB first as specified in the datasheet, so it is written in reverse as 29H.

MOV A,ADRESS ; 92H ADDRESS Information will be sent.

CALL SEND1

SETB MODGITTI ; Mode information is sent, set the flag bit.

MOV A,IN2_BAYT1 ; Configuration information for FM band.

CALL SEND1

MOV A,IN2_BAYT2

CALL SEND1

MOV A,IN2_BAYT3

CALL SEND1

CLR CE

CLR TR0 ; Stop the Timer.

RET
;------------------------------------------------------------------------
; In this subroutine, the information loaded to A is shifted one bit to the right using the RRC instruction for each SET occurrence of the timer overflow bit. The bit shifted to the right is taken to the C bit. Then, this bit taken to the C bit is sent to the DI terminal for each SET occurrence of the overflow bit. The number 08 loaded to address 90h indicates that 8 bits of information will be transferred.
;------------------------------------------------------------------------
SEND1:

MOV 90H,#08 ; 8 bits (1 Byte) of information will be sent.

LOOP:

RRC A ; rotate the bit to the right, take the bit that goes out to Carry.

MOV DI,C ; Send the bit in Carry to the DI input of LC72131.

TAMBA:

JB MODGITTI,TUMBA ; If the mode information is sent, branch to set CE.

JNB TF0,$ ; Wait until overflow occurs (15 microseconds have passed).

CLR TF0 ; Overflow occurred, clear the overflow flag.

CLR CLK ; Reset the CLK pin.

JNB TF0,$

CLR TF0

SETB CLK ; Make the CLK pin high.

JNB TF0,$

CLR TF0

CLR CLK ; Make the CLK pin low.

DJNZ 90H,DONGU ; Repeat the process until all 8 bits are sent.

JMP FINISH ; 8 bit sending is finished.

TUMBA:

CALL CE_ON

CLR MODGITTI

JMP TAMBA

END: RET
;------------------------------------------------------------------------
CE_ON: ; Subroutine to make CE pin high.

TF0,$

CLR TF0

SETB CE ; Make CE pin high.

RET
;------------------------------------------------------------------------

We write the codes in Notepad++ text editor and save them to the computer by giving them a name with .ASM extension (E.g.: Tuner.asm).

We convert the file we saved with .ASM extension to a .HEX extension file by running ASM51.exe assembler program. (Tuner.hex in our example)

We plug the USB ASP programmer into the USB port and make the necessary settings. We also connect the programming pins (MOSI, MISO, etc.) of the AT89S52 microcontroller to the relevant pins of the USBASP programmer.

After making sure of all the hardware connections, we run the ProgISP program and download our .HEX extension file (Tuner.hex) to our microcontroller.

After the download process is completed, when we reset the microcontroller, we start listening to the radio station at 90Mhz from the radio output.

Share any questions, suggestions or opinions you may have regarding the project with me.

GOOD LUCK!!

THE TWENTYTH DAY OF NOVEMBER 2023 AD

20/11/2023 MATEKS ELECTRONICA/MEXICO

mateksmakina@hotmail.com





Comments

Popular posts from this blog