Order this document by AN494/D Rev. 1 Freescale Semiconductor AN494 Freescale Semiconductor, Inc... An HC11-Controlled Multiband RDS Radio By Peter Topping Motorola, Ltd. East Kilbride, Scotland This application note describes the software and hardware features of the microcontroller (MCU) of a synthesized multiband radio which includes RDS (radio data system) decoding (FM, band II). It uses an MC68HC(7)11 MCU whose program can be on-chip or contained in an external EPROM (erasable programmable read-only memory). ROM versions are available. Both LCD (liquid crystal display) and VFD (vacuum fluorescent display) 16-character dot matrix display modules can be used to display RDS and tuning information. Traffic messages, initiated by the reception of EON (enhanced other networks) data (group 14B) or TA = TP = 1 (traffic announcement = traffic program = 1) on the current frequency, are handled. The station carrying the TA is tuned for the duration of the message, followed by a return to the original frequency. A tuning knob employing an incremental encoder is supported. Introduction Figure 1 shows a block diagram of the application. The controller hardware and software are described in detail here. The other hardware is not covered to the same depth, because that varies between different implementations, the intention being to describe a controller which could © Freescale Semiconductor, Inc., 2004. All rights reserved. © Motorola, Inc., 2001 For More Information On This Produ Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note be added to an existing radio or to one which includes only one or two of the possible bands. Freescale Semiconductor, Inc... Separate FM and AM PLLs (phase-locked loop) are shown. This is not essential, but it reduces the amount of band switching necessary and simplifies hardware fault finding. The illustrated configuration corresponds to that used by the author for software development and debugging. 4 BBC4 FM 21:40 RDS DEMOLATOR C IRQ M68HC11 INCREMENTAL ENCODER FM TUNER MC 145170 D STEREO & AUDIO ÷5 XIRQ MC 145157 AM TUNER MC 14028 BRAND SELECT SW MEM. SELECT FM IF SELECT DISPLAY SELECT LCD MUX IRQ CONTROL RDS TA 9/10 : SL – TA TEST + 7 4 8 5 9 6 AL S/S 1 0 STANDBY MUTE TA = TP = 1 M/S 3 2 MODECL ST ONOFF Figure 1. Main Block Diagram The MCU used is the MC68HC(7)11. The MC68HC711K4 (K4) [and similar chips such as the MC68HC711P2 (P2) and MC68HC711PH8 (PH8)] can be used in expanded mode, but this application has been included in the ROM of an E32 and a PH8. To use the ROMed parts in this application, the first three bytes of EEPROM (electrically erasable programmable ROM) should contain an extended jump to the appropriate start address. The E32 (ZC403311) requires $7E, $90, and $00 at addresses $B600, $B601, and $B602, while the PH8 (ZC428200 or ZC428202) requires $7E, $40, and $00 at AN494 2 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Introduction Freescale Semiconductor, Inc... addresses $0D00, $0D01, and $0D02. This can be done using either PCbug11 or the BUFFALO (bit users fast friendly aid to logical operation) monitor (see reference 5). The E32 version uses all the input/output (I/O) and can, therefore, be used only in single-chip mode. The circuit diagram of the HC11E controller is shown in Figure 3 and the circuit diagram of the K4/PH8 in Figure 4. The K4/PH8 version shows the additional hardware (within the dotted line) used to develop and debug the software on a K4 using PCbug11. This implementation uses two of the K4’s chip selects to enable external memories allowing debug to be done with the code in RAM and the PCbug11 talker in an EPROM. This arrangement requires a further four I/O (input/output) lines, leaving 30 for use in the application. The description of the application, and the listed software, corresponds to the E32 ROMed version (ZC403311). Later sections list the port allocation and functional differences which apply to the PH8 ROMed versions (ZC428200 and ZC428202). Forty programs (10 on FM, 10 on MW and 20 on SW) can be stored using the HC11E’s on-chip EEPROM (the PH8 has 20 additional SW (shortwave) programs). Each contains frequency, an 8-character name [PS (program service) name on a station with RDS] and, on FM only, PI (program identification) code and a TA inhibit bit. For stations with no RDS (for example, all AM stations), the saved name can be manually entered. Programs saved with no name use their frequency instead. The SW banks are selected by an I/O line (two for the PH8). When the MCU is reset, or any of the band or memory select inputs are changed, the last used program in the selected band is tuned. This feature does not require that the MCU is permanently powered up, as this information is also stored in non-volatile EEPROM. The keyboard uses an MC14028 decoder to minimize the number of I/O lines used. Either LCD or VFD 16-digit dot matrix displays can be used. The VFD display driver supported is the MSC7128, and the LCD driver the HD44780. This driver on its own provides a 16-way multiplexed LCD. In conjunction with an HD44100, it can facilitate an 8-way multiplexed higher contrast display. The input level on a port pin selects the appropriate type of multiplexing to match the display in use. To minimize the I/O activity, only one display is driven, the choice between LCD and VFD again being determined by an I/O line. AN494 3 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note MC145170 and MC145157 PLLs are supported, using the same data and clock lines as the VFD driver, along with dedicated chip selects. The MC145157 requires an external prescaler for frequencies above 20 MHz, but the MC145170 has an on-chip 160-MHz capability. Freescale Semiconductor, Inc... A tuning knob can be included by using an incremental encoder. This can utilize either IRQ or XIRQ. As IRQ is used for the RDS clock, XIRQ is most appropriate for the tuning function. The possibility of using IRQ (see information described later) has been included to facilitate debug with PCbug11, which can employ XIRQ for its communication with the PC. Edges detected on the encoder execute the PS edit and alarm setup functions of the +/– (plus/minus) keys, depending on the direction of rotation. This provides a quick and convenient method of editing the PS name and changing the alarm time. A difference in function between the encoder and the +/– keys applies in normal mode. The program number is not affected by the tuning knob. In this mode, when the +/– keys control the program number, the tuning knob increments or decrements the frequency. Two I/O lines are used to select the band. These lines are regularly monitored; if they change, the radio is retuned to the last used station in the selected band. Table 1 shows the bands which are available. • Band 2 is intended for single-conversion (low IF, intermediate frequency) MW or SW radios. The large step size of 9 or 10 kHz is suitable for MW rather than SW, but the small step size of 1 kHz is suitable for either SW or MW. • Band 3 is for dual-conversion (10.7-MHz first IF) SW designs. The FM IF offset is selected as + or –, according to the level on port A, bit 2 (high: LO high; low: LO low). • Bands 0 and 1 both are intended for VHF/FM, the difference between them being in the use of the M68HC11’s IRQ pin. It is possible to use IRQ interrupts for both RDS and the tuning knob, as the two functions are not required simultaneously. To facilitate this, the band-select inputs affect the function performed when an edge is detected in the IRQ pin. When band 0 is selected, an RDS bit is read, but in any other band the incremental encoder function is performed. This enables automatic selection of function if bit 0 AN494 4 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Introduction on port A is taken high when movement is detected from the shaft encoder. This facility can be disabled (RDS function only) by holding bit 3 of port A low. This should be done if XIRQ is being used for the tuning knob. As XIRQ is level-sensitive, some additional components are required to interface it with the incremental encoder. Figure 2 shows a simple circuit which can be used for this purpose. Freescale Semiconductor, Inc... Table 1. Available Bands Band PA1 PA0 IF Offset Step Memory Use Prescaler MC145157 Only 0 0 0 +/–10,700 50, 10 10 VHF 10 1 0 1 +/–10,700 50, 10 10 VHF 10 2 1 0 455 9 (or 10), 1 10 MW/SW — 3 1 1 10,700 5 20/40 SW 5 5V 10 kΩ x 2 100 kΩ 1N914 E5 INCREMENTAL ENCODER 1N914 XIRQ 1nx2 100 n H C 1 1 1M Figure 2. Incremental Encoder Interface Circuit AN494 5 For More Information On This Product, Go to: www.freescale.com TA SL 8 5 2 MODE RDS : 7 4 1 0 ST CL 3 6 9 – 9/10 RDS DEMODULATOR ON 6 For More Information On This Product, Go to: www.freescale.com 19 IRQ 46(49) E5 18 XIRQ 44(47) E4 31(34) A3 MOD B MOD A RESET 0.1 µ VLCD 3 Figure 3. MC68HC11E32 Circuit 33p 33p 8.388 MHz BAND & MEM C D E 5V A6 A5 28 29 (31) (32) E7 A7 A2 D5 A4 M/S 5V VFD LCD +8 +16 (DISP. SEL.) (LCD MUX) +10.7 (FM IF) –10.7 STANDBY MUTE MC145157 MC145170 ~ 5 V –HT Vf VFD MODULE TA = TP = 1 50(53) 27(30) 33(36) 25(26) 30(33) B3 39(42) 41(44) B1 42(45) B0 42 41 40 (45) (44) (43) B0 B1 B2 38(41) B4 10 kΩ 100 kΩ x3 E6 A1 A0 48 33 34 (51) (36) (37) 52-PIN PLCC (56-PIN SDIP) MC68HC11E32 37 36 35 9 (40) (39) (38) 16 B5 B6 B7 C D0 D7 – 1 14 7 LCD MODULE + 10 µ RS R/W E 4 6 5 2 + E3 E2 E1 E0 –VSS– VRL EXTAL XTAL (21) 1 (56) 51 7 10 M 8 (54) 49(52) 47(50) 45(48) 43(46) 7 6 Q6 16 1 Q5 5V + Q4 M 15 Q3 C 12 24(25) C D4 1 2 Q2 4 0 B 13 23(24) D3 14 Q1 2 8 A 10 22(23) D2 D – 8 11 10 kΩ x4 OFF S/S AL + TA TEST 3 INCREMENTAL ENCODER 3 2 17 VDD VRH 26 52 (29) (27) (55) 10 kΩ x3 2 M C 3 1 4 0 6 4 5V Freescale Semiconductor, Inc... Freescale Semiconductor, Inc. Application Note AN494 For More Information On This Product, Go to: www.freescale.com 0 1 4 7 RDS + SL 10 kΩ x4 6 1 Q5 Q4 9 8 AL M 15 Q3 C 5 6 S/S 1 2 Q2 4 2 3 0 14 ST ON Q1 2 MODE CL OFF 8 D 11 — TA TEST INCREMENTAL ENCODER TA RDS DEMODULATOR 3 2 M C 1 3 4 0 6 4 5V 13 76 D3 39 40 41 42 3 G4 G2 A 84-PIN PLCC MC68HC11K4 (PH8) G3 29 1 31 30 78 RS R/W E D0 D7 – 1 14 10 µ 4 6 7 5 + LCD MODULE VLCD C D E 18 H6 H4 16 13 H1 12 H0 G0 33 D5 77 A0–A7 A8 B0 A9 B1 A10 B2 A11 B3 A12 B4 A13 B5 CSPROG H7 21 A10 24 A9 9 (-) 53 (-) 55 (-) 46 (-) 11 (-) 10 (-) 10 19 A0 25 A8 3 A7 2 A12 23 A11 8 (-) 27 1 2 7 C 6 4 + PGM VPP 20 CE 26 NC 28 7 (-) 6 (-) 19 (-) 5V MUTE STANDBY PLLs (5157 / 5170 ~ 5 V –HT Vf VFD MODULE 17(–) CSGP1 H5 26(–) R/W G7 32(–) XA14 G1 12 13 14 H0 H1 H2 10 kΩ BAND & MEM Figure 4. MC68HC11K4 and PH8 Circuit 8.388 MHz 7 D0 — OE 14 22 D7 A0 2 13 15 + 11 10 19 24 A9 25 A8 3 A7 23 A11 21 A10 26 A13 2 A12 M C M 6 0 2 5 6 5V 28 + 20 CE 27 R/W 1 A14 VCC VDD C1- C1+C2- C2+VSS GND 10 2 T3 I3 MC145407 9 3 12 O3 R3 11 D7 DATA C E3 D0 62 (-) 11 OE — E2 14 22 E1 VRL EXTAL XTAL A7 E7 E6 G8 G5 D0 D1 XIRQ E0 –VSS– 5V 78 3 24 45 63 43 67 68(66) 72 73 21 35 36 27 28 10 M (PH8 ONLY) (-) (-) (-) 5V 22 µF x 4 100 kΩ 10 10 + + + kΩ kΩ 100 kΩ x4 33 p 19 17 18 20 3 14 33 p A 10 74 D2 – 8 B 12 76 D4 54 IRQ 37 E5 21 XIRQ 38 E4 15 A3 7 Q6 16 + 5V C 0.1 µ 2 23 34 64 44 69 –V – V DD RH (70) RESET 71 MODA (20) MODB 70 10 kΩ x4 2 + RS 232 (25-WAY) Freescale Semiconductor, Inc... Freescale Semiconductor, Inc. Application Note Introduction AN494 7 Freescale Semiconductor, Inc. Application Note Frequency Synthesis Freescale Semiconductor, Inc... Synthesis of the local oscillator (LO) in a superheterodyne radio provides many advantages over mechanical tuning. The main benefits are: • Tuning accuracy • Stability • Storing of often-used frequencies. The accuracy and stability result from the fact that the LO is phaselocked to a crystal oscillator. In conjunction with RDS, frequency synthesis provides the additional facility of allowing the radio to retune itself to a traffic announcement or news bulletin. A synthesizer can be retrofitted to most radios by replacing the tuning capacitor with a varicap diode. The voltage biasing the varicap is supplied by the synthesizer and also can be used to provide RF (radio frequency) tuning. Alternatively, manual preselector or no RF tuning can be employed. Motorola’s MC145157 and MC145170 synthesizers are two of a series offering a variety of options including serial or parallel interfacing and single or dual modulus prescaling. The MC145157 requires a prescaler for frequencies above 20 MHz but the MC145170 can handle input frequencies up to 160 MHz. The MC145157 has been included to retain compatibility with hardware developed for use with the MC68HC05B4 synthesizer described in ANE416 (reference 1). Figure 5 shows the block diagram of the MC145170. It uses the Motorola bitgrabber system, whereby the number of bits sent determines the register which is written to. There is, therefore, no need for the control bit which is required by the MC145157. AN494 8 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Frequency Synthesis OSCIn 1 OSCOut 2 15-STAGE R COUNTER OSC fR CONTROL 9 fR 15 4-STAGE REFERENCE DIVIDER REFOut 3 CLOCK Freescale Semiconductor, Inc... DATA IN DATA OUT 7 SHIFT REGISTER AND CONTROL LOGIC 5 8 3 BITGRABBER R REG 15 BITS LOCK DETECTOR AND CONTROL 11 LD 16 BITGRABBER C REG 8 BITS 13 PHRASE/FREQUENCY DETECTOR A & CONTROL PDOut POR ENABLE 6 14 PHRASE/FREQUENCY DETECTOR B & CONTROL 15 ∅R ∅V BITGRABBER N REG 16 BITS 16 fIn 4 INPUT AMP fV CONTROL 10 fV 16-STAGE N COUNTER Figure 5. MC145170 Block Diagram The reference counter divides the 8-MHz crystal oscillator (10 MHz for the MC145157) down to the reference frequency (in this case, 1 kHz for the MC145157 and 10 kHz for the MC145170) at which the comparison is made with the (also divided down) local oscillator. The filtered output of the phase comparator supplies the tuning voltage to the local oscillator. The numbers chosen as the divide ratios determine the frequency at which this oscillator stabilizes. The equation that follows shows the relationship between the various frequencies where P is the LO prescaler (MC145157 only). The received frequency can be changed by altering the LO divide ratio. The MCU takes care of the decimal-tobinary conversion, IF offset, and the other arithmetic required. LO frequency = RF + IF = P x [(Xtal frequency) / (ref. divide ratio)] x LO divide ratio The MC145157 is specified to operate up to 20 MHz, so prescaling is required on FM and SW (10.7-MHz IF). For this SW band, divide-by-5 AN494 9 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Freescale Semiconductor, Inc... prescaling is used; for FM, divide-by-10 is used. This increases the minimum step size to 10 kHz of FM, which is ideal for this band, and to 5 kHz on SW, which is suitable for almost all broadcast stations. The MC145170 does not require any prescaling even on the FM band and can use this to advantage by allowing the use of a higher reference frequency, making the low-pass filter design less critical. An important part of any PLL is the loop filter. The filter in Figure 6 is an active filter using the double-ended phase detector outputs from the MC145170 feeding a CA3460 operational amplifier. This dual op-amp allows the simple double-ended low-pass filter to be followed by a second order Sallen and Key filter. An active filter has the added advantage of increasing the available voltage swing beyond the supply rail of the MC145170/MC145157. 12 V 3 7805 1 2 100 n 8.0 MHz 62 kΩ 16 VDD 1 OSC In 100 n 30 pf 10 n 100 n CA3620 10 M 47 pf 1n LO 2 OSC Out ∅R 14 ∅V 15 150 kΩ 7 150 kΩ 4 f In 100 µ 6 5 4k3 47 n 100 n µC B4 38 B1 41 B0 42 6 E 5 D 7 C 3 8 27 kΩ VSS 12 10 n 2 62 kΩ 4 1 10 kΩ TUNING 2k2 22 kΩ MC145170 4n7 10 kΩ 10 n Figure 6. MC145170 Circuit AN494 10 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Radio Data System Freescale Semiconductor, Inc... The combination of active filter and double-ended phase detector outputs makes it simple to select the correct relationship between voltage and frequency. Usually, the fixed side of the varicap diode is grounded, so increased voltage increases the frequency of the oscillator; in some oscillator designs, the fixed side may be taken to the supply rail, and increasing the voltage will decrease the frequency. With the filter design shown here, the choice can be made simply by swapping the phase detector outputs from the PLLs. Radio Data System The radio data system (RDS) adds a digital data capability to the FM VHF transmissions on band II (87.5 to 108 MHz). The specification is defined in CENELEC EN 50067 (formerly EBU Technical Document 3244, see reference 2). An MC68HC05E0 implementation of RDS is described in AN460, (reference 5). It monitors the RDS activity on the MPX signal of a VHF radio but is not able to tune the radio and, therefore, cannot, use AF (alternative frequencies) or EON data. This application can tune the radio and uses EON data to retune the radio when a traffic announcement is taking place on another frequency. An announcement is initiated by a packet 14B and the radio retunes if TAs are enabled. At the end of the TA, the original station is re-tuned. TAs are not active in standby mode (standby line high). To transmit the data, a subcarrier is added at 57 kHz. This subcarrier is amplitude-modulated with the shaped bi-phase coded data signal. The subcarrier itself is suppressed to avoid data modulated cross-talk in phase-locked-loop stereo decoders and to maintain compatibility with the German ARI system which uses the same subcarrier frequency. Information is sent in groups of four 26-bit blocks. Each group of 104 bits is one of several types containing different information. It is up to the broadcaster to decide which features are transmitted as long as the specified format is adhered to and PI, PTY, and TP are included. Each group contains a different subset of the RDS features; a list of all currently defined features is shown in Table 2. AN494 11 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note The retrieval of data is carried out by demodulation hardware, which generates clock and data signals that can be used by the MCU. Suitable devices which can perform this function include SAA6579, SAA7579T (plus an external filter), TDA7330, LA2231, and RDS hybrids. Table 2. RDS Features Freescale Semiconductor, Inc... Feature Information PI Program identification PTY Program type PS Program service name RT Radiotext CT Clock time and date AF Alternative frequencies TA Traffic announcement TP Traffic program MS Music/speech switch DI Decoder identification PIN Program item number EON Enhanced other networks TDC Transparent data channel INH In-house data This application supports PI, PTY, PS, RT, CT, TP, TA, MS, DI, PIN, and EON. These features facilitate permanent display of the 8-digit station name (PS) and time (CT), and, on request, can display program type (PTY), radiotext data (RT), and the status of the other RDS information (see Table 5). EON data can be displayed and used to switch to traffic announcements, but the retuning features associated with AF are not supported, as they are appropriate only for a radio intended for use in a vehicle. In a car radio, AF data would be used to tune the radio to the strongest signal carrying the selected service. PI is a 2-byte number which identifies the AN494 12 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Radio Data System country, coverage area, and service. It can be used by the control MCU but is not normally intended for display. A change in PI code causes the initialization of all RDS data as it indicates that the radio has been retuned. This application facilitates the display of the current PI code. Freescale Semiconductor, Inc... PTY is a 5-bit number which indicates the current program type. At present, 16 of these types are defined. Examples include "no programme type," "Current affairs," and "Pop music," although the actual syntax which is displayed is determined by the software of the controlling MCU. In this example, PTY can be displayed on request; Table 3 shows the display used for each PTY code. PS is the 8-character name of the station and is permanently displayed (except in standby mode). In the absence of RDS (for example, AM bands), the name can be entered manually. If none is entered, then the frequency is used as the station name when the program is stored in EEPROM. Radiotext (RT) constitutes a string of up to 64 characters which give additional information regarding the service or program currently being transmitted. In this application, RT is displayed on request on the 16-digit dot matrix displays, using scrolling. The data often contains extra spaces to center the text on a 2 x 32 character display. As these are not appropriate for a 16-character scrolling display, the software reduces all sequences of two or more spaces to a single space. CT (clock time and date) data is transmitted every minute on the minute and provides a very accurate clock, traceable to national standards. The (modified Julian) date and local time variation are also transmitted. Time is permanently displayed. In standby mode (see information later), the date is displayed instead of the PS name. The MJD number, which is the form in which the date is received, can also be displayed. The MCU converts this number into day-of-week, day-of-month, month and year. AF would be used by a car radio to retune to the strongest signal carrying the selected service. AF data, along with TDC (transparent data channel) and INH (in-house data), is not used in this application. TA and TP are flags. TP is set if the transmitter normally carries traffic information and TA is set if a traffic announcement is in progress. The AN494 13 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note combination — TA = 1 and TP = 0 — is used to indicate that EON data is being used to supply information on other networks, including traffic announcements. A port line (port A, bit 5) is asserted (low) when TA = TP = 1. This can be used to demute or switch from another source (for instance, cassette when a TA occurs). Table 3. PTY Types Freescale Semiconductor, Inc... PTY Display 0 no program type 1 News 2 Current affairs 3 Information 4 Sport 5 Education 6 Drama 7 Culture 8 Science 9 Varied 10 Pop music 11 Rock music 12 Easy listening 13 Light classics 14 Serious classics 15 Other music 16–31 no program type M/S is a single bit indicating either music or speech and is intended to be used to make a tone or volume adjustment to a radio’s audio stage. The M/S bit is displayed on request. A port line (port A, bit 6) is asserted (low) when M/S = 1. This can be used to control external hardware. AN494 14 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Radio Data System Decoder information (DI) constitutes four bits indicating the type of transmission (mono, stereo, binaural, etc.). Currently, it is not in use in the United Kingdom, but it can be displayed as a number between 1 and 15. Freescale Semiconductor, Inc... Program item number (PIN) is used to identify the program currently being broadcast. The format is a 2-byte number which includes the scheduled time and date (day of month) of the start of the program. PIN can be displayed as four hexadecimal digits or fully decoded to day of month and time. EON (enhanced other networks) replaces the older ON format. If type 14 groups are used to provide EON data, then type 3 groups (ON) will not be used. Type 14A groups are used to send information about other networks. The PS name and principal frequency of up to 16 other networks can be displayed. Type 14B groups are used to switch to traffic announcements; they include the PI code of the station carrying the announcement. This PI code is searched for in NVM, and the required station is tuned if it is stored in NVM. This method allows the user to select which TAs are allowed (they will not occur if the station is not in NVM or if its TA inhibit bit is set) and avoids attempts to jump to an announcement which is not relevant or not receivable with sufficient signal strength to be useful. Keyboard The keyboard has 23 keys. Table 4 shows the layout and Table 5 contains a summary of key functions against mode. Table 4. Keyboard Layout PE0 PE1 PE2 PE3 Q6 RDS Traffic MW step TA test Q5 Time colon Sleep — + Q4 7 8 9 Alarm Q3 4 5 6 Store Q2 1 2 3 Q1 0 Manual Clear/Step On/Off AN494 15 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note The following functions are available. On/Off This key is intended as an on/off control for the radio. It sets a port line low for on and high for standby and can be used to control the power supply to the radio. Its status affects the behavior of other keys as described later in this application note. ON/OFF Freescale Semiconductor, Inc... Sleep When pressed, the 1-hour sleep timer starts, leaving the standby line low (radio on) until the sleep time has elapsed. At this time, the line is switched to the standby mode (high). In the normal display mode, the sleep timer running causes the decimal point to appear on the display modules’ first character. The sleep timer can be cancelled by pressing ON/OFF. The sleep time can be reduced in increments of five minutes by repressing or holding down the SLEEP key. SLEEP Alarm The alarm key selects the alarm display mode and toggles the alarm armed status. When the alarm is not armed, the legend ALARM-OFF is displayed. When it is armed, the alarm time is shown and adjustment of the alarm setup can be done by selecting the field (5/7 day, hours, or minutes) with the STORE/SET key. The selected field (hours or minutes) flashes and can be adjusted with the +/– keys or the tuning knob. The alarm setup display returns to normal three seconds after the last adjustment. If the radio is in standby mode and the alarm is set, the alarm time is displayed instead of the date. The radio will come fully on (standby line low) at the alarm time. After a 500-ms delay to allow power supplies to stabilize, the program which was tuned when the radio was last used is retuned. When set to the 5-day alarm, the alarm will not occur on Saturdays and Sundays. ALARM Plus (+) and Minus (–) + and — Pressing + or –, while in normal mode, increments or decrements the program number. The program number wraps round at 0 and 9. The mute line is set high before retuning and returned low 100 ms after the new frequency has been sent to the PLL. Changing the tuned program using the +/– keys (or the 0–9 keys) disables PS name clearing if RDS information is absent or contains multiple errors. AN494 16 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Radio Data System Freescale Semiconductor, Inc... In PS-edit mode (see entry that follows), the + and – keys are used to change the character at the cursor position. This function is duplicated on the tuning knob incremental encoder. In the alarm setup mode, the + and – keys are used to change the alarm time as described earlier. The field which is currently selected for adjustment (using the STORE key) flashes. This function is duplicated on the tuning knob also. In manual mode, these keys increment and decrement the current frequency in steps of 10 kHz or 50 kHz (FM) as selected by the CLEAR/STEP key. The default is 10 kHz. On the SW band, 1-kHz (455 kHz IF only) or 5-kHz steps are available; on the MW/LW band, 1or 9-kHz steps are available. In the U.S.A., 10 kHz is appropriate instead of 9 kHz; this can be selected with a special key (see entry that follows). This function is duplicated on the tuning knob both in this mode and in normal mode. Use of the +/– keys (or the incremental encoder) to adjust the frequency enables PS name clearing if RDS information is absent or contains multiple errors. In normal mode, on the AM bands, use of the tuning knob displays the frequency in the PS name field, facilitating simultaneous display of frequency and time. Store/Set STORE/SET In normal modes (not manual or alarm), the store key selects the PS-edit mode in which the first character of the displayed PS-name flashes and can be changed by the + and – keys or the tuning knob. Subsequent presses of STORE move to the next character. A space is shown as a hyphen (–). This mode returns to the normal display mode 10 seconds after the last key press. This mode can be used to give a name to a station with no RDS PS name (all AM stations or an FM station with no RDS or with RDS or unusable quality). See the entry that follows for the method of saving this name in EEPROM. Entry of a PS name in this way requires that PS name clearing is disabled. This is achieved by changing the program number (by using the +/– or 0–9 keys). Fine tuning enables PS name clearing (see +/– key description). Direct frequency entry does not affect the PS name clearing status. In the alarm setup mode, STORE selects what will be changed when the + or – keys or the tuning knob are used (5/7 day, hours, or minutes). Hours or minutes flash when they are selected. AN494 17 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Freescale Semiconductor, Inc... In manual mode, STORE enters a special manual store mode in which the 9–0 keys save, rather than recall, a program. After pressing STORE, the program number flashes to indicate this change of function. Alternatively, a second press of STORE saves the current tuning information into the current program number. The current frequency, PI code (FM), PS name, and TA inhibit flag (FM) are saved in EEPROM. The TA inhibit status can be changed using the TRAFFIC key (see entry that follows). If the PS edit mode has been used, then manual store mode should be used to save the entered PS name. Manual MANUAL Select manual entry of frequency; a second press returns to normal mode if the tuned frequency has not been changed. If it has been changed, the second press retunes to the new frequency and an additional press is required to return to the normal mode. In manual mode, frequency is displayed instead of the time; the + and – keys or the tuning knob enable incrementing and decrementing of the current frequency. Direct entry of frequency can be made using 0–9 keys. In this mode, the STORE key enters the manual store mode in which the program number flashes, allowing storing of the tuned program and PS name into the current, or a different, program number. A second press of STORE saves the current frequency, PS name, PI code, and TA inhibit bit (FM) in EEPROM. In manual mode, the TRAFFIC (TA) key controls the TA inhibit bit, which can be stored with each program. If the current station has its TP flag high, the least significant digit of the frequency will alternate with a decimal point. Pressing TP toggles the NVM inhibit bit. When inhibited, the decimal point between the MHz and kHz becomes a "–". A subsequent press of STORE saves this bit in NVM along with the frequency, PI code, and PS name. 0 to 9 0 to — 9 These keys are used both for direct frequency entry and for recalling the 40 available programs. In all modes, except standby and manual, when a 0–9 key is pressed, the selected program is tuned. Changing the tuned program using the 0–9 keys (or the +/– keys) disables PS name clearing if RDS information is absent or contains multiple errors. In manual mode, these keys are used for the direct entry of frequency. After entering the required frequency, pressing MANUAL retunes to the new frequency. AN494 18 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Radio Data System The mute line is set high before retuning and returned low 100 ms after the new frequency has been sent to the PLL. In manual store mode, the program number flashes and the 0–9 keys save the tuned program into the selected program number in EEPROM. RDS Freescale Semiconductor, Inc... RDS Traffic TRAFFIC Clear/Step CLEAR/STEP TA Test TA TEST Time Colon TIME COLON The first press displays scrolling RT data. Subsequent presses display PTY code, PI code, TA and TP, PIN code (two formats), MJD, MS and DI, last TA PI code, the reason for returning from last TA and EON (up to 16 networks with their principal frequency). See Table 5 for the display formats. The RDS key is operational in all modes except standby. Enable/disable traffic switching. When disabled, this is indicated by a decimal point in the 11th character of the dot matrix displays. Default at power-up is enabled. The TRAFFIC key works in all modes except standby. During manual mode and manual store mode, it toggles the TA inhibit status, which can subsequently be saved in NVM. Toggles between 10-kHz and 50-kHz steps on the FM band or between 1 and 9 kHz (or 10 kHz) on the MW band. There is no indication on the dot matrix displays. In manual mode, the displayed frequency is cleared to facilitate the entry of a new frequency. If the clear is followed by use of the + or – keys or the tuning knob, the original frequency is retained, allowing a change of step size only. In PS edit mode, the clear key clears the current PS name. Pressing TA test simulates the arrival of a group 14B. The PI code of the other network is embedded in the code (C5B1, Radio Clyde in the ROMed version). This key enables or disables the flashing colon in the time display. This can be used to prevent unnecessary I/O activity thus reducing RFI. Disabling the colon prevents 1-Hz updating, as the display modules are only updated if the data to be displayed has changed. AN494 19 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note MW Step This optional key selects 9- or 10-kHz steps on MW. Nine kHz is appropriate in Europe and 10 kHz in the United States. The default is 9 kHz, and the key need not be implemented if 10 kHz will never be required. MW STEP Freescale Semiconductor, Inc... Table 5. Key Function by Mode On/Off Sleep Alarm +/– Store Manual TP RDS 0–9 Clear Standby (OFF) mode normal (ON) mode sleep (ON) mode alarm — — — — — — — Normal (ON) mode standby (ON) mode PS-edit mode manual display “ +/– prog. tune prog. PS edit A off “ “ “ “ +/– ASCII “ “ mode alarm on +/– prog. — 5/7 day toggle mode setup toggle traffic enable flag RT toggle step 10/ 50 kHz PTY next char. “ “ “ “ PI “ “ “ “ “ “ “ “ input freq. “ save prog. & clear freq. TA TP PIN hex L on A “ “ mode alarm off R M setup M A N U A store L “ “ PIN dec “ “ MJD M/S DI hour/min +/– toggle hour/min “ “ TA ret. TA PI “ “ “ “ mode alarm “ +/– freq. mode store “ save prog. mode normal “ toggle traffic enable NV bit EON (16) “ AN494 20 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Circuit Circuit Freescale Semiconductor, Inc... The circuit is in two distinct parts. The circuit for the MC145170 synthesizer is shown in Figure 6. The synthesizer board is the only part of the synthesizer controller which actually needs to be in (or close to) the radio. A local oscillator signal to supply the synthesizer should be taken from a low-impedance point so that the oscillator is not significantly loaded. Pulling of the oscillator frequency is not a problem as the PLL circuitry will compensate, but loading the tuned circuit itself is not recommended unless a high-impedance buffer is included. This prevents affecting the tuning range or the "Q" of the oscillator. The MC145157 requires a divide-by-10 prescaler for FM and divide-by-5 for band 3. The MC145170 does not require prescaling. The standard LP1186 FM tuner does not have an LO take-off but a signal can be taken, without other modification, from the emitter of the oscillator BF195 (near the center of the PCB). The Mullard LP1186 is unusual in having its local oscillator low. More recent tuners, for instance, the Larsholt 7254/55, almost always have their local oscillator above the tuned frequency. This selection can be made using port A, bit 2. A 16-digit LCD (parallel) or VFD (serial) dot-matrix display module can be driven. The two display modules show the same data (within the limitations of their character ROMs). The VFD display driver supported is the MSC7128 and the LCD driver, the HD44780. On its own, this driver can be used to provide a 16-way multiplexed display, but an 8-way multiplexed higher contrast display is possible if the module also incorporates an HD44100. In an application which drives an LCD module (for instance, a ROMed PH8) and the module is not connected, a 10-k pulldown resistor should be added to bit 7 of port A. This prevents the software hanging up waiting for the busy line to go low. Figure 3 and Figure 4 show the circuit diagrams of the controllers. Figure 3 gives the pin numbers for the 52-pin PLCC HC11E with the numbers for the 56-pin SDIP (if different) in brackets. With the E32, the display in use can be selected by the level on port E, bit 7 (high for LCD and low for VFD) and the LCD multiplexing by port A, bit 7 (high for AN494 21 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Freescale Semiconductor, Inc... divide-by-16, low for divide-by-8). The SW bank is selected by the level on port E, bit 6. Figure 4 shows pin numbers for the 84-pin PLCC K4, with the differences for the PH8 in brackets. Debug on the K4 using PCbug11 (reference 5) requires some additional hardware (within the dotted line) and port D bits 0 and 1 (SCI), port G bits 1 and 7 (XA14 and R/W), and port H bits 5 and 7 (CSGP1 and CSPROG), leaving 30 input/output (I/O) lines for use in the application. The display selections are not available on the PH8 ROMed versions, but there are four SW banks of 10 program memories; they are selected by port E, bits 6 and 7. Since different demodulator devices can be used, the circuitry for the demodulator is not shown. The clock from the demodulator interrupts the microprocessor on each positive edge. At this time, a data bit is available and is read on bit 5 of port E. Software An assembled listing of part of the HC11E32 ROMed version (ZC403311) of the application is included. The software is in three modules and was assembled and linked using the Introl re-locatable assembler and linker. The first module is listed. It contains all the main control routines, including the main loop and keyboard scanning, and the function to be performed by each key. The second module contains the RDS and display functions, while the third module is the 4-function, 9-digit integer BCD arithmetic required for the MJD date calculations. The second and third modules are described and listed in AN495 (reference 4). EB419/D (reference 5) describes and lists additional debug code contained in the ROMed parts. The code which is executed only on startup (power-on or reset) begins at the label START on the third page of the first module’s listing, while the main loop starts at the label IDLE on the next page. The idle loop is quite long, as many functions and checks have to be carried out. AN494 22 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Software Freescale Semiconductor, Inc... These include: • Pacing the loop using the main timer • Checking to see if the display needs updating or if a transient display has timed out • Checking if alarm is armed and, if so, comparing its time with the current time • Sleep timer operation • Traffic announcement timing and return • Keyboard scanning and selected function execution • Incremental encoder execution • Checking for changes in the band and memory selection inputs • Timing band changes • Updating TA = TP = 1 and M/S outputs The keyboard subroutine (KBD) is executed at 64 Hz from the idle loop and checks to see if a key is pressed. If the same key is pressed on three consecutive tries, its function is performed. The remainder of the first module constitutes the subroutines performed by each key and the arithmetic and serial activity required to tune the synthesizers. The batch files used for linking the modules are shown as comments at the end of the listing, along with the pseudo-vectors required by PCbug11 during debug. The displays are only updated when there is a change in the displayed data. At 8 Hz, a check is made to see if any characters have changed; if there has been a change, the display update routine is executed. This is done to minimize interference caused by communication with the displays. The colon between the hours and minutes of the time display changes at 1 Hz. This can be disabled (colon permanently displayed) by using the time colon key. The display routine (MOD) is executed in the idle loop if the flag bit 3 of STAT2 is set. It is set every 125 ms by timer B interrupts. If flag bit 4 of STAT2 is set, the display is initialized, indicating no valid RDS data. The dot-matrix modules are then updated, if necessary, with new data. Each time, before anything is written to the LCD module, the subroutine WAIT is used; this checks that the controller AN494 23 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Freescale Semiconductor, Inc... in the module is not busy. The different display formats are selected by checking the various flags and the relevant routine executed. The normal display permanently shows PS name and time. As the locations in RAM used for hours and minutes contain binary numbers, they are converted to BCD before being written to the relevant bytes in DISP. Once all 16 bytes in DISP have been loaded, loops are used to send the data to the display modules. The standby display (alarm not enabled) shows date and time. After a power-up, the display "Mon 0 inv 0:00" indicates that the date and time are invalid. The date and time will be correct once a valid RDS CT group has been received. The VFD routine sends the same data as is shown on the LCD module to the serial VFD module. The display driver used has a different character set from the standard ASCII set used by the LCD module. The table VTAB is used to convert ASCII data into the required character in the VFD module. The small table INITF is used to send the required initialization bytes to the VFD module. This module does not require a busy check but does require a delay between successive bytes. This is satisfied by the wait loop within the serial output loop VFDL. The LCD and VFD routines are in the second software module (see reference 4). Table 6. Display Formats Display Mode Standby Off Alarm off Alarm off, no CT Alarm on Normal On With RDS PS name Without RDS Auto name Tuning knob (AM) Alarm Alarm off Alarm on/setup Sleep Format Thu 12 May 21:35 Mon 0 inv 0:00 0659 alarm 21:35 4 BBC 4 FM 21:40 5 ----------- 21:40 6 -- 9410 21:40 6 -- 9415 21:40 Alarm — OFF 5-day alarm 0659 Sleep 60 minutes AN494 24 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Traffic Announcements Table 6. Display Formats (Continued) Display Mode Freescale Semiconductor, Inc... RDS RT PTY PI TA & TP PIN (hex) PIN (decoded) MJD MS & DI last TA 1. 2. EON (16) Manual Format Kaleidoscope. . . . Culture PI code — C204 TP — 0 TA — 1 PIN no. — 655E 12th at 21:30 MJ day — 49484 M/S M DI 01 last TA PI C514 TA rtrn: EON PI BBC 3 FM 92.10 BBC Gael 103.70 BBC Nwcl 96.00 BBC Scot 94.30 BBC Scot 92.50 BBC Scot 94.70 BBC Scot 93.50 Classic 101.70 BBC Eng 107.90 BBC 1 FM 99.50 BBC 2 FM 89.90 --------------------------6 Classic 101.70 Traffic Announcements The radio can respond to EON-initiated traffic announcements if they are enabled by the TRAFFIC (TA) key. This status is indicated by a decimal point at the 11th character on the dot-matrix displays. A switch to a TA on another frequency will only occur if the station has previously been stored in NVM; the EON data which can be displayed using the RDS key is not used for TA switching. The PI code of the last TA (or attempted TA) can be displayed by pressing the RDS key eight times. A further press displays one of the TA return/inhibit messages shown here. TAs which are the result of TA = TP = 1 on the current frequency do not update the last TA PI or TA return/inhibit messages. AN494 25 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Freescale Semiconductor, Inc... When a 14B group is received, the following occurs: • Check traffic flag; if enabled, proceed; otherwise, set TA rtrn/inhb message to: TA inhb: flag — Traffic key inhibit flag (d.p. at the 11th character position) • Search for TA PI code in NVM; if found, proceed; otherwise, set TA rtrn/inhb message to: TA inhb: EON PI — The PI code given in 14B is not in the NVM. • Check station TA inhibit flag in NVM; if clear, proceed; otherwise, set TA rtrn/inhb message to: TA inhb: NVM — User inhibit of station using bit stored in NVM • Retune to frequency stored in NVM against EON PI code. The PS name display changes to show the PS name of the service carrying the traffic announcement and the time display is replaced by the new frequency. If the service has its TP flag high, then the 10s of kHz digit will flash as in the manual mode display. After one second, check TP flag at the new frequency. If high, then proceed; otherwise, return to original frequency and set TA rtrn/inhb message to: TA rtrn: TP low — TP station does not have TP bit high. • Check PI code at new frequency. If correct (same as 14B EON TA PI code), then proceed; otherwise, retune to original frequency and set TA rtrn/inhb message to: TA rtrn: PI code — PI code of TP station was not as expected. • After an additional two seconds, start to monitor the TA flag; if high, remain on current frequency, if low, return to original frequency and set TA rtrn/inhb message to: TA rtrn: TA low — TA flag of TP station low. This is the normal return method. • If, during a TA, the radio is manually retuned, the TA rtrn/inhb message is set to: TA rtrn:manual — User-initiated manual return AN494 26 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Traffic Announcements Table 7. MCU I/O Freescale Semiconductor, Inc... K4 and PH8 Function E32 Port A bits 0–7 LCD module data bus Port C bits 0–7 Port B bits 0–7 High-order addresses (K4) N/A — Port C bits 0–7 Data bus (K4) N/A — 0–1 2–4 5 Debug (PCbug11 or BUFFALO) Keyboard rows (via 14028 encoder) Standby (high:standby, low:on) Port D bits Port D bits 0–1 2–4 5 Keyboard columns Shaft direction (XIRQ) RDS data in or shaft direction (IRQ) Short-wave memory select 1 Short-wave memory select 2 (PH8 only) Port E bits Port E bits 0–3 4 5 6 7 N/A 0–3 4 5 6 — Port F bits 0–7 Low-order addresses N/A — Port G bits 0 1 2–4 5–6 7 Mute XA14 (K4 only) LCD control lines (RS, R/W, and clock) Band select R/W (K4) Port A bit N/A Port B bits Port A bits N/A 4 — 5–7 0–1 — Port H bits 0–1 2 3 4 5 6 7 Serial clock/data for VFD and PLLs VFD chip enable (PH8: +/– 10.7 MHz) Port E, bit 5 input control MC145170 PLL chip enable CSGP1 (K4 only) MC145157 PLL chip enable CSPROG (K4 only) Port B bits Port B bit Port A bit Port B bit N/A Port B bit N/A 0–1 2 3 4 — 3 — N/A FM IF select (+/– 10.7 MHz Port A bit 2 N/A TA = TP = 1 Port A bit 5 N/A M/S = 1 Port A bit 6 N/A LCD multiplex select (8/16) Port A bit 7 N/A Display module (LCD/VFD) select Port E bit 7 AN494 27 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Setup and Testing Freescale Semiconductor, Inc... An effective method of fault finding a PLL circuit is to initially do the tuning with a potentiometer, leaving the output of the filter disconnected from the VCO. As the radio is tuned through the frequency setup in the synthesizer, the filter output should switch from one extreme to the other. Until this test passes, it is not useful to close the loop, as it is difficult to distinguish the cause of a problem from its effects. Check operation of the MC34064 LVI circuit. As the supply voltage is lowered, it should pull the reset pin low. This should occur between 4.70 and 4.50 volts. Adjust trimmer on the EXTAL pin of the M68HC711 for accurate timekeeping in the absence of RDS CT information. (Radio should be detuned or tuned to a station known not to provide RDS.) The trimmer on pin 2 of the PLL chip (MC145157 or MC145170) should be adjusted to provide an accurate reference frequency. This adjustment can be made simply to tuning to a strong broadcast of known frequency and adjusting for optimum reception or symmetric adjacent-channel response. PH8 ROMed Application The ROMed PH8s (ZC428200 and ZC428202) differ from the described E32 version of this application as follows: 1. 40 short-wave programs can be stored instead of 20. These are accessed by the use of a second memory-select line (port E, bit 7). 2. There is no display selection; both LCD and VFD signals are generated. If an LCD module is not connected, a pulldown on port A, bit 7 should be included (see Figure 4). 3. LCD multiplexing is fixed at divide-by-8. 4. Traffic announcement (retune to TA frequency) is not fully implemented in the ZC428200. AN494 28 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note References 5. Time colon FLASH defeat key is not implemented; the display modules are always updated at 8 Hz. 6. TA = TP = 1 and M/S outputs are not implemented. Freescale Semiconductor, Inc... 7. 10-kHz MW steps are not available (no 9/10 key). 8. +/–10.7-MHz IF selection (FM) is carried out on port H, bit 2 which is read after reset but before it is set up as an output. A pullup or pulldown resistor will determine the IF selection (pullup for LO high and pulldown for LO low) without affecting the pin’s subsequent function as an output (VFD chip enable). 9. The 500-ms delay at switch-on between the standby line moving and the PLLs being retuned is not implemented. 10. The sleep d.p. flashes during operation of the sleep timer. References 1. A Radio Synthesizer Using the MC68HC05B4, Motorola document order number ANE416/D 2. CENELEC EN 50067, Specifications of the Radio Data System (RDS), formerly EBU technical document 3244 3. An RDS Decoder Using the MC68HC05E0, Motorola document order number AN460/D 4. RDS Decoding for an HC11 Controlled Radio, Motorola document order number AN495/D 5. ROMed HC11E32 and HC11PH8 Including BUFFALO Monitor and PCbug 11 Talker, Motorola document order number EB419/D AN494 29 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Code Listing Freescale Semiconductor, Inc... ************************************************************* * * * MC68HC11E32 RDS multiband radio. * * * * Used with RDSE.S11, FNCE.S11 & RDRAME.S11. * * * * P. Topping 3rd April ’94 * ************************************************************* IMPORT SDATA,TINTB,INITD,MOD,CLOCK,MJDAT,WAIT,CLREON,CBCD, PROC, TFCC EXPORT DCON2,NEW,CLTR,SHAFT LIB RDRAME.S11 PORTA PORTB PORTC PORTD PORTE PORTCD PORTDD TMSK2 PACTL OPTION INIT EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU $00 $04 $03 $08 $0A $07 $09 $24 $26 $39 $3D PORT " " " " PORT " RBO PPROG ND EQU EQU EQU $1000 $3B 9 REGISTER BLOCK OFFSET EEPROM CONTROL REGISTER No. DIGITS A ADDRESS B " C " D " E " C DATA DIRECTION REG. D " " " SECTION.S .RAM1,COMM BMJD Q TMQ R TMP R MJD YR MNTH DOM DOW RMB RMB RMB RMB RMB RMB RMB RMB RMB RMB RMB 3 9 9 9 9 9 9 9 2 2 1 BINARY MJD WORKING NUMBER 1 - RDS SCRATCH WORKING NUMBER 2 - RDS MULT. OVER. OR DIV. REMAINDER WORKING NUMBER 3 - RDS MODIFIED JULIAN DAY NUMBER YEAR MONTH DATE DAY OF WEEK ******************************************** * * * RAM allocation, RDS & radio. * * * ******************************************** DIST SLEPT RDSTO PSNP DAT TMPGRP GROUP PTY PTYCMP PI PION PIN LEV BIT ITMP1 SYN RMB RMB RMB RMB RMB RMB RMB RMB RMB RMB RMB RMB RMB RMB RMB RMB 1 1 1 1 4 8 8 1 1 2 2 2 1 1 1 2 TRANSIENT DISPLAY, TIMEOUT,COUNTER SLEEP TIMER MINUTES COUNTER RDS TIMEOUT COUNTER PS DISPLAY POINTER SERIAL DATA BUFFER TEMPORARY GROUP DATA COMPLETE GROUP DATA PROGRAM-TYPE CODE (CURRENT) PROGRAM TYPE CODE (PTY SCAN) PROGRAM IDENTIFICATION CODE PROGRAM IDENTIFICATION CODE (EON) PROGRAM ITEM NUMBER VALID BLOCK LEVEL BIT LEVEL TEMP BYTE FOR USE IN IRQ SYNDROME AN494 30 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Code Listing Freescale Semiconductor, Inc... CONF TH32 TH8 SEC MIN OUR AMIN AOUR DISP1 DISP2 RMB RMB RMB RMB RMB RMB RMB RMB RMB RMB 1 1 1 1 1 1 1 1 1 1 6 RQ RMB 6 RP RMB 6 RR RMB 2 W1 RMB 2 W2 RMB 2 W3 RMB 2 W4 RMB 2 W5 RMB 2 W6 RMB 2 W7 RMB 2 KEY RMB 1 KOUNT RMB 1 DIG2 RMB 1 CARRY RMB 1 COUNT RMB 1 NUM1 RMB 2 NUM2 RMB 2 LED RMB 1 SMEM RMB 2 REARET RMB 1 RTDIS RMB 1 DI RMB 1 SCHAN RMB 1 ******************************************** * * * Flags, & pages 1-2. * * * ******************************************** SYNDROME CONFIDENCE TICS (SECONDS/32) EIGHTHS OF SECONDS SECONDS MINUTES HOURS ALARM MINUTES ALARM HOURS RT DISPLAY POINTER #1 RT DISPLAY POINTER #2 STAT * * * * * * * STAT2 * * * * * * * STAT3 * * * * * * * STAT4 * * * * * * * STAT5 * * * 0: 1: 2: 3: 4: 5: 6: 7: 0: 1: 2: 3: 4: 5: 6: 7: 0: 1: 2: 3: 4: 5: 6: 7: 0: 1: 2: 3: 4: 5: 6: 7: 0: 1: 2: 3: RMB 1 RMB 1 RMB 1 RMB 1 RMB 1 WORKING BCD NUMBER 1 RADIO " " " 2 " " " " 3 " W O R K I N G CODE OF PRESSED KEY KEYBOARD COUNTER 2nd DIGIT TIMEOUT COUNTER BCD CARRY LOOP COUNTER 1ST No. POINTER (ADD & SUBTRACT) 2ND No. POINTER (ADD & SUBTRACT) STATION NUMBER CURRENT FREQUENCY LAST TA REASON FOR RETURN RDS DISPLAY TYPE DECODER IDENTIFICATION SCAN CHANNEL MODE 1: STATION, 0: FREQ STEP 1: 50KHz, 0: 10KHz CLRQ 1: CLEAR IF NO. KEYED TIMER MS BIT TOGGLE (64 Hz) RDS DATA CLEARING ENABLE KEY FUNCTION PERFORMED KEY REPEATING NOT JUST POWERED UP VALID SYNDROME VALID GROUP RT DISPLAY UPDATE DISPLAY CLEAR DISPLAY SPACE FLAG NOT ON PROGRAM (AM) TA RETUNE DONE NOT ON PROGRAM (FM) TEXTA/TEXTB BIT (RT) TA FLAG TP FLAG SHAFT DIRECTION SHAFT ROTATION UPDATE DATE SHAFT INTERRUPTS DISPLAY (OR TA SWITCH) TRANSIENT SLEEP TIMER RUNNING TRAFFIC ENABLED ALARM DISPLAY ALARM ARMED ALARM SET-UP ALARM HOURS (SET-UP) VALID GROUP 14B RECEIVED BAND CHANGE TIMEOUT RDS DISPLAYS SLEEP DISPLAY M/S 0: M, 1: S AN494 31 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note * * * * STAT6 BCTO SCNT EON Freescale Semiconductor, Inc... DISP DISPP PSN RT STRST TMRB IRQ 4: 5: 6: 7: RMB RMB RMB 1 1 1 RETUNE FLAG (FREQUENCY MODE) TA INHIBIT FLAG (NVM) STORE MODE WEEKDAY ONLY ALARM BAND/BANK (,MW STEP,COLON, ,A1,A0,,E6) BAND CHANGE TIMEOUT SHAFT DETENT COUNTER SECTION .RAM2,COMM RMB 256 SECTION .RAM3,COMM RMB 16 RMB 16 RMB 8 RMB 69 SECTION .ROM1 JMP START JMP TINTB JMP SDATA EON DATA (16 NETWORKS) LCD MODULE BUFFER CURRENT LCD MODULE CONTENTS RADIOTEXT RESET VECTOR RTI IRQ ******************************************** * * * Reset routine - set-up ports etc. * * * ******************************************** START H2L * * LDAA STAA LDAA STAA #$01 INIT #$10 $1035 LDAA STAA LDAA STAA LDAA STAA LDAA STAA #$30 $1039 #$03 $1026 #$40 $1024 #$00 $1028 IRQ EDGE SENSITIVE LDS #$02FF INITIALISE STACK POINTER LDY LDAA STAA #$1000 #$10 PORTA,Y 0,1: 3: 6: LDAA STAA #$00 PORTB,Y 0,1: SERIAL CLOCK/DATA, 5,6,7: LCD CONTROL 2,3,4: LATCH SIGNALS (VFD, 5157 & 5170) CLR LDAA STAA PORTC,Y #$FF PORTCD,Y 0-7: LCD PARALLEL BUS CLR LDAA STAA PORTD,Y #$3C PORTDD,Y 0,1: 2-4: 5: SCI (DEBUG) KEYBOARD OUTPUTS STANDBY 0-3: 5: KEYBOARD INPUTS, 4: SHAFT INPUT (XIRQ) RDS/SHAFT INPUT, 6: SW BANK, 7: LCD/VFD REGISTERS AT $1000 ENABLE EEPROM WRITE (NOT CONFIG) 32Hz RTI (8.388MHz XTAL) PORTA, BITS 3 & 7 INPUTS ENABLE REAL TIME INTERRUPTS DWOM = 0, PORTD PUSH-PULL PORTE " BAND INPUTS (FM, FM, MW, SW), 2: FM IF IRQ CONTROL, 4: MUTE, 5: TA=TP=1 M/S=1, 7: 8/16 LCD MUX ******************************************** * * * INITIALISE LCD AND RAM. * * * ******************************************** CLOOP JSR LDAA JSR JSR LDAA JSR DBOUNC #$30 CLOCK DBOUNC #$30 CLOCK WAIT 15ms LDX CLR #BMJD 0,X INITIALISE PAGE 0 RAM INITIALISE LCD WAIT 15ms INITIALISE LCD AN494 32 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Code Listing Freescale Semiconductor, Inc... M8 INX CPX BNE BSET BSET #SCNT+1 CLOOP STAT4,$04 STAT,$01 LDAA JSR JSR LDAA BRCLR LDAA JSR JSR LDAA JSR JSR LDAA JSR JSR JSR #$30 CLOCK WAIT #$30 PORTA,Y,$80,M8 #$38 CLOCK WAIT #$08 CLOCK WAIT #$01 CLOCK INITD CLREON MORE ? ENABLE TRAFFIC SWITCHING - DEFAULT ? STATION MODE INITIALISE LCD /8 DISPLAY /16 DISPLAY LATCH IT SWITCH DISPLAY OFF LATCH IT CLEAR DISPLAY LATCH IT INITIALISE RDS DATA & DISPLAY AND EON DATA * Initialise interrupt JMPs JRT1 JIRQ JXIRQ EQU EQU EQU $00EB $00EE $00F1 E32 BUFFALO RAM JUMP TABLE " " " " " " " " " " LDAA STAA STAA STAA LDD STD LDD STD LDD STD #$7E JRTI JIRQ JXIRQ #TINTB JRTI+1 #SDATA JIRQ+1 #SHAFTX JXIRQ+1 RTI LDAA TAP #$00 ENABLE IRQ & XIRQ IRQ XIRQ ******************************** * * * Idle loop. * * * ******************************** IDLE LDY BRSET BRSET BSET BRA BRCLR BCLR #$1000 STAT,$08,TBH $0E,Y,$80,* STAT,$08 NO2D $0E,Y,$80,* STAT,$80 BRCLR LDAA BNE JSR STAT4,$01,NOPS DIST NOPS CLTR YES, TIMED OUT ? NOPS BRCLR JSR BCLR STAT2,$08,NDU MOD STAT2,$08 DISPLAY UPDATE REQUIRED ? YES, DO IT AND CLEAR FLAG NDU BRCLR PORTD,Y,$20,FULON STANDBY ? NOTSNZ NTJ2 BRSET JMP STAT4, $10,NNT2 NT2 STANDBY, ALARM ARMED ? NNT2 BRCLR LDAA CMPA BHI LDAA CMPA STAT5,$80,NWA DOW #4 NT2J AOUR OUR YES, WEEKDAY ALARM ONLY ? YES SATURDAY OR SUNDAY ? NO, COMPARE ALARM HOURS WITH TIME TBH NO2D NWA DISPLAY TRANSIENT ? AN494 33 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note ONAG Freescale Semiconductor, Inc... FULON BNE LDAA CMPA BNE LDAA BNE BCLR JSR BCLR JSR NT2J AMIN MIN NT2J SEC NT2 PORTD,Y,$20 DEL500 PORTA,Y,$10 P5170 SAME ? YES, COMPARE ALARM MINUTES WITH TIME SAME ? ONLY ALLOW WAKE-UP IN FIRST SECOND TO PREVENT SWITCH-OFF LOCKOUT YES, SWITCH ON, WAIT 500ms, DEMUTE AND TUNE (5170 & 5157) BRCLR LDAA BNE BCLR BSET BSET STAT4,$02,FLN SLEPT FLN STAT4,$02 PORTD,Y,$20 PORTA,Y,$10 SLEEP TIMER RUNNING ? YES TIME TO FINISH ? YES, CLEAR FLAG, SWITCH OFF AND MUTE ******************************** * * * Idle loop (cont.). * * * ******************************** FLN * * * * SOK TPOK PINOK1 NT1 NWWS NT2 ANTI NSRO BRCLR BRSET BSET CLR LDAA STAA BSET BSET JSR JSR BRCLR JSR BRCLR LDAA STAA BRA JSR BRSET LDAA STAA BRA LDAA CMPA BNE LDAA CMPA BEQ LDAA STAA STAT4,$80,NT1 STAT2,$80,NT2 STAT2,$80 REARET #25 DIST STAT4,$01 PORTA,Y,$10 DBNC RETUNE2 STAT4,$80,NWWS DEL500 PORTE,Y,$10,SOK #2 REARET NT1 DEL500 STAT3,S08,TPOK #5 REARET NT1 PI PION PINOK1 PI+1 PION+1 NT2 #3 REARET 14B FLAG HIGH ? YES, BIT AGREES ? NO, SET BIT BRCLR BCLR BSET JSR BCLR LDAA JSR STAT2,$80,NT2 STAT4,$80 PORTA,Y,$10 DBNC STAT2,$80 LED RETUNE2 14B FLAG LOW, BIT AGREES ? MAKE SURE 14B CANCELLED MUTE WAIT 150 ms CLEAR FLAG SELECTED PROG. AND RETURN TO ORIGINAL PROGRAM JSR JSR BRCLR BCLR BRSET JSR BRA JSR BRCLR JSR KBD KEYP STAT3,$20,NSRO STAT3,$20 STAT3,$10,ANTI PINC2 NSRO PDEC2 STAT3,$40,NRDSP MJDAT READ KEYBOARD EXECUTE KEY SHAFT ROTATION PENDING ? YES, CLEAR FLAG DIRECTION ? CLOCKWISE, INCREMENT LOCK OUT RETURN FOR 3 SECONDS SET DISPLAY TRANSIENT FLAG MUTE WAIT 150 ms AND RETUNE PI CODE NOT IN EON LIST ? WAIT 500ms SIGNAL OK ? WAIT 500ms TP OK? YES, CHECK PI CODE AGAINST PI (EON) IF OK STAY SWITCHED ANTI-CLOCKWIRE, DECREMENT UPDATE DATE ? YES, CONVERT FROM MJD ********************************************* * * * Idle loop (cont.). * AN494 34 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Code Listing Freescale Semiconductor, Inc... NRDSP * Retune if band or SW bank inputs changed. * * * ***************************************** LDY #$1000 BRCLR STAT,$80,BTO JUST POWERED UP ? BRCLR PORTA,Y,$01,L5 NO, A0 LOW ? BRSET STAT6,$04,CG6 NO, HIGH, BIT AGREES ? BSET STAT6,$04 NO, MAKE IT HIGH BRSET STAT6,$08,BTO BAND ONE ? BSET STAT3,$80 YES, SHAFT INTERRUPTS BRA CHE AND NOTHING ELSE TO DO L5 BRCLR BCLR BRSET BCLR BRA STAT6,$04,CG6 STAT6,$04 STAT6,$08,BTO STAT3,$80 CHE YES, A0 LOW, BUT AGREES ? NO, MAKE IT LOW BAND ZERO ? YES, RDS INTERRUPTS AND NOTHING ELSE TO DO CG6 BRCLR BRSET BSET BRA PORTA,Y,$02,L6 STAT6,$08,CHE STAT6,$08 BTO A1 LOW ? NO, HIGH, BIT AGREES ? NO, MAKE IT HIGH L6 BRCLR BCLR BRSET BCLR BRA STAT6,$08,CHE STAT6,$08 STAT6,$04,BTO STAT3,$80 BTO YES, A1 LOW, BIT AGREES ? NO, MAKE IT LOW BAND ZERO ? YES, RDS INTERRUPTS CHE BRSET BRA STAT6,$0C,BD3 OK6 BAND 3 ? BRCLR BRSET BSET BRA PORTE,Y,$40,E6L STAT6,$01,OK6 STAT6,$01 BTO NO, E6 LOW ? NO, HIGH, BIT AGREES ? NO, MAKE IT HIGH E6L BRCLR BCLR STAT6,$01,OK6 STAT6,$01 YES, E6 LOW, BIT AGREES ? NO, MAKE IT LOW BTO BSET LDAA STAA BSET STAT,$80 #10 BCTO STAT5,$01 SET POWER-UP FLAG, BD3 CE6 INITIALISE AND START BAND-CHANGE TIMEOUT ******************************** * * * Idle loop (cont.). * * * ******************************** OK6 BRCLR DEC BNE BCLR BSR BRCLR BSET STAT5,$01,ARI BCTO ARI STAT5,$01 RCLP STAT6,$0C,ARI STAT3,$80 TIMEOUT RUNNING? YES, DECREMENT COUNT FINISHED ? YES, CLEAR FLAG AND RECALL LAST USED PROG. No. BAND 0 ? NO, SHAFT INTERUPTS ARI BRSET BSET BRA BCLR STAT3,$0C,TATP PORTA,Y,$20 IOOK PORTA,7,$20 TA=TP=1 ? MSH BRSET BSET BRA BCLR STAT5,$08,MSH PORTA,Y,$40 IDLJ PORTA,Y,$40 IDLJ JMP IDLE RCLP BSET LDAB JSR STAA PORTA,Y,$10 #120 READ1 LED TATP IOOK YES, A5 LOW M/S=1 ? YES, A6 LOW MUTE GET STORED PROG. No. AN494 35 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note JMP RETUNE2 PROGRAM 145170/57 ******************************** * * * Shaft rotation interrupts. * * * ******************************** SHAFT SEM TEM Freescale Semiconductor, Inc... SHAFTX XEM YEM BRSET BCLR BRA BSET BSET RTI PORTE,Y,$20,SEM STAT3,$10 TEM STAT3,$10 STAT3,$20 IRQ,SHAFT I/O HIGH (E5) ? NO, CLEAR DIRECTION BIT BRSET BCLR BRA BSET BSET RTI PORTE,Y,$10,XEM STAT3,$10 YEM STAT3,$10 STAT3,$20 XIRQ, SHAFT I/O HIGH (E4) ? NO, CLEAR DIRECTION BIT YES, SET DIRECTION BIT SET FLAG TO INDICATE ROTATION YES, SET DIRECTION BIT SET FLAG TO INDICATE ROTATION ******************************** * * * Keyboard routine. * * * ******************************** KBD KEY1 L1 EXIT NOTCH NRML GON2 GOON2 CLR LDY LDX LDAB ADDB STAB LDAB ANDB ADDB STAB LDAA BITA BNE DEX BNE CLR BRA LDAB LSLB LSLB LDAA ANDA ABA CMPA BEQ STAA CLR INC LDAA BRCLR LDAB BEQ CMPA BRA CMPA BRA CMPA BLO BEQ CMPA BHI LDAA BEQ CLC RTS LDAA CMPA BEQ W1 #$1000 #7 W1 #$04 W1 PORTD,Y #$20 W1 PORTD,Y PORTE,Y #$0F L1 SELECT COLUMN PRESERVE OTHER PORTD DATA READ KEYBOARD ANY INPUT LINE HIGH ? NO, TRY NEXT COLUMN LAST COLUMN ? YES, NO KEY PRESSED KEY1 KEY EXIT W1 PORTE,Y #$0F READ KEYBOARD KEY EXIT KEY KOUNT KOUNT KOUNT STAT,$40,NRML PSNP NOTCH #8 GON2 #16 GON2 #3 KCLC GOON #47 GOON2 KEY RKEY SAME AS LAST TIME ? NO, SAVE THIS KEY YES, THE SAME REPEATING ? YES CHARACTER CHANGE ? YES, REPEAT AT 8 Hz NO, REPEAT AT 4 Hz NO, 3 THE SAME ? IF NOT DO NOTHING IF 3 THEN PERFORM KEY FUNCTION MORE THAN 3, MORE THAN 47 (750mS) ? TIME TO DO SOMETHING ? NO KEY PRESSED ? YES BUT DO NOTHING KEY #$54 GOON3 DEC. PROG. AN494 36 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Code Listing GOON3 GOON RKEY DNT2 Freescale Semiconductor, Inc... KCLC DNT CMPA BEQ CMPA BNE BSET CLR LDAA BEQ SEC RTS BCLR BCLR CLR CLC RTS #$58 GOON3 #$52 DNT2 STAT,$40 KOUNT KEY RKEY INC.PROG. STAT,$20 STAT,$40 KOUNT NO, CLEAR DONE FLAG CLEAR REPEAT FLAG CLEAR COUNTER SLEEP IF NOT A REPEAT KEY, DO NOTHING SET REPEAT FLAG SOMETHING TO DO ? YES, SET C ******************************** * * * Execute key. * * * ******************************** KEYP KEYP2 RPT RJ PJ BCC LDAA CMPA BEQ CMPA BEQ CMPA BEQ BRSET CLRB LDX ABX LDAA CMPA BEQ CMPA BEQ ADDB BRA BSET JSR JMP DNT KEY #$54 RPT #$58 RPT #$52 RPT STAT,$20,DNT ANYTHING TO DO ? YES, GET KEY DEC. PROG. (M) INC. PROG. (S) SLEEP NOT A REPEAT KEY, FLAG SET ? #CTAB 0,X KEY PJ LAST DNT #4 RJ STAT,$20 1,X P5170 FETCH KEYCODE THIS ONE ? YES NO, LAST CHANCE ? YES, ABORT NO TRY THE NEXT KEY ******************************** * * * Keyboard jump table. * * * ******************************** CTAB FCB JMP FCB JMP FCB JMP FCB JMP FCB JMP FCB JMP FCB JMP FCB JMP FCB JMP FCB JMP FCB JMP FCB JMP $11 DIGIT $21 DIGIT $22 DIGIT $24 DIGIT $31 DIGIT $32 DIGIT $34 DIGIT $41 DIGIT $42 DIGIT $44 DIGIT $48 ALARM $38 SAVE 0 1 2 3 4 5 6 7 8 9 ALARM STORE/SET AN494 37 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Freescale Semiconductor, Inc... Application Note LAST FCB JMP FCB JMP FCB JMP FCB JMP FCB JMP FCB JMP FCB JMP FCB JMP FCB JMP FCB JMP FCB JMP $18 ONOFF $14 CLEAR $12 MODE $52 SLEEP $54 PDEC $58 PINC $61 RTDSP $62 TPEN $64 T910 $51 TFCC $68 TEST ON/OFF CLEAR/STEP MODE (PROG./FREQ.) SLEEP TIMER START DEC. PROG./FREQ./CHAR. INC. PROG./FREQ./CHAR. RDS DISPLAYS TRAFFIC ENABLE (TOGGLE) MW STEP 9/10kHz (TOGGLE) COLON CONTROL TA TEST ******************************** * * * Alarm key. * * * ******************************* ALARM ALOF ADON UDCNT ABOA BRCLR BRCLR BCLR BRA BSET BRA STAT4,$08,ADON STAT4,$10,ALOF STAT4,$10 UDCNT STAT4,$10 UDCNT ALARM DISPLAY ON ? YES, ALARM ON ? YES, SWITCH OFF JSR BSET BCLR LDAA STAA BSET RTS CLTR STAT4,$08 STAT4,$20 #25 DIST STAT4,$01 NO, ENABLE ALARM DISPLAY ALARM DISPLAY FLAG CANCEL SET-UP 3 SECONDS TIMEOUT NO, SWITCH ON SET DISPLAY TRANSIENT FLAG ******************************** * * * On/off key. * * * ******************************** ONOFF SODM ALRON JSR BCLR BCLR CLTR STAT4,$82 STAT5,$40 CLEAR DISPLAY TRANSIENTS CANCELL SLEEP TIMER & TA SWITCH FLAG CANCEL STORE MODE BRCLR BCLR JSR BCLR RTS BSET BSET RTS PORTD,Y,$20,ALRON PORTD,Y,$20 DEL500 PORTA,Y,$10 ON ? NO, SWITCH ON WAIT 500ms AND DEMUTE PORTD,Y,$20 PORTA,Y,$10 YES, SWITCH OFF AND MUTE ******************************** * * * PS name clear. * * * ******************************** PSC CPSL LDX LDAA STAA INX CPX BNE RTS #PSN #$FF 0,X #PSN+8 CPSL AN494 38 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Code Listing ******************************** * * * TP. * * * ******************************** TPEN TAEH HIGH NS1 Freescale Semiconductor, Inc... TPOF BRSET BRSET BRSET BSET RTS BCLR RTS PORTD,Y,$20,HIGH STAT,$01,NS1 STAT5,$20,TAEH STAT5,$20 STANDBY ? NO, NORMAL MODE ? NO, FREQ. MODE, NVM DISABLE FLAG SET ? NO, SET IT STAT5,$20 YES, CLEAR IT BRCLR BCLR RTS BSET RTS STAT4,$04,TPOF STAT4,$04 NORMAL MODE, TRAFFIC ON ? YES, DISABLE STAT4,$04 NO, ENABLE ******************************** * * * Sleep timer. * * * ******************************** SLEEP INSLP SLEP STR DECS SLPTOK BRSET BRSET LDAA STAA BSET JSR BSET BRA LDAA SUBA STAA BMI STAT5,$04,DECS STAT4,$02,STR #60 SLEPT STAT4,$02 CLTR STAT5,$04 SLPTOK SLEPT #5 SLEPT INSLP LDAA STAA BSET BRSET BCLR RTS #25 DIST STAT4,$01 PORTD,Y,$20,SODM PORTA,Y,$10 ALREADY SLEEP DISPLAY ? NO, SLEEP TIMER ALREADY RUNNING ? NO, INITIALISE SLEEP TIMER START SLEEP TIMER YES, CLEAR DISPLAY TRANSIENTS SLEEP DISPLAY NO DECREMENT IF FIRST TIME DECREMENT SLEEP TIMER START DISPLAY TRANSIENT ALREADY ON ? YES, JUST DEMUTE ******************************** * * * Number entry routine. * * * ******************************** DIGIT SHIFT AGS BRSET JSR LSRB LSRB BRSET BRSET BSET BLCR STAB BRCLR BCLR JSR BSR LDX LDAA STAA INX CPX BNE LDAA STAA RTS PORTD,Y,$20,AB03 CLTR STANDBY ? NO, CLEAR DISPLAY TRANSIENTS STAT,$01,SKP STAT5,$40,SKP STAT5,$10 STAT5,$20 W3 STAT,$04,SHIFT STAT,$04 CLQ DR1 W1 1,X 1,X STATION MODE ? NO, STORE MODE ? NO, SET RETUNE FLAG (FREQUENCY MODE) AND CLEAR TA INHIBIT BIT (NVM) W2 AGS W3 0,X CLEAR Q ? YES, CLEAR FLAG AND CLEAR Q W1: MSD, W2: LSD MOVE ALL DIGITS UP ONE PLACE DONE ? YES, RECOVER NEW DIGIT AND PUT IT IN LSD AN494 39 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note SKP BSET TBA STAA JMP PORTA,Y,$10 MUTE LED RETUNE ******************************** * * * Save pointers & 500ms delay. * * * ******************************** DR1 ABO3 Freescale Semiconductor, Inc... DEL500 LDX STX LDAB ABX STX RTS #RQ W1 #5 LDX JSR LDX JMP #255 SKDB #255 SKDB STORE POINTERS W2 ******************************** * * * Increment key (& knob). * * * ******************************* PINC2 PINC TOG57J BRSET BRSET BRSET LDAB BNE JMP STAT4,$20,ALSU1 STAT4,$08,TOG57 PORTD,Y,$20,DMI PSNP PSN0 UP ALARM SET-UP ? NO, ALARM DISPLAY ? NO,STANDBY ? NO,PS EDIT MODE ? NO, STEP UP BRSET BRSET STAT4,$20,ALSU1 STAT4,#08,TOG57 ALARM SET-UP ? NO, ALARM DISPLAY ? BRSET BRSET JMP PORTD,Y,$20,DMI STAT,$01,NACS UP NO, STANDBY ? NO, FREQ. MODE ? YES, STEP UP ******************************** * * * Alarm inc. (hours/minutes). * * * ******************************** ALSU1 TOOH IHR HTOH T5S DMI NACS BRSET LDAA CMPA BHS INC BRA CLR BRA LDAA CMPA BLO CLR BRA INC LDAA STAA BSET BCLR RTS STAT4,$40,IHR AMIN #59 TOOH AMIN T5S AMIN T5S AOUR #23 HTOH AOUR T5S AOUR #80 DIST STAT4,$01 PORTA,Y,$10 LDAB BEQ PSNP CONTI YES, SET-UP HOURS ? NO, MINUTES 10 SECOND TIMEOUT SET DISPLAY TRANSIENT FLAG DEMUTE NO, PS EDIT MODE ? AN494 40 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Code Listing ********************************************** * * * P-S Edit inc. (ASCII) and 5/7 day toggle * * * ********************************************** Freescale Semiconductor, Inc... PSN0 MAK20 MAK2E MAK30 MAK41 MAK61 CNTB TOG57 A7 LDX ABX LDAA INCA CMPA BLS CMPA BLS CMPA BLO CMPA BLS CMPA BLO CMPA BLS CMPA BLO CMPA BLS LDAA BRA LDAA BRA LDAA BRA LDAA BRA LDAA STAA LDAA JMP #PSN-1 BRCLR BRCLR BCLR BRA BSET BRA STAT4,$10,DMI STAT5,$80,A7 STAT5,$80 T5S STAT5,$80 T5S 0,X YES INCREMENT ASCII VALUE SPACE LESS OR EQUAL ? NO, . LESS OR EQUAL ? NO, 0 LESS ? NO, 9 LESS OR EQUAL ? NO, A LESS ? NO, Z LESS OR EQUAL ? NO, a LESS ? NO, z LESS OR EQUAL ? MAKE SPACE #$20 MAK20 #$2E MAK2E #$30 MAK30 #$39 CNTB #$41 MAK41 #$5A CNTB #$61 MAK61 #$7A CNTB #$20 CNTB #$2E CNTB #$30 CNTB #$41 CNTB #$61 0,X #80 OUTCH MAKE . MAKE 0 MAKE A MAKE a ALARM ARMED ? YES, 7-DAY ALARM ? NO, MAKE IT 7 DAY YES, MAKE IT 5 DAY ******************************** * * * Program number increment. * * * ******************************** CONTI IOK BSET BSET LDAA BRSET INCA CMPA BLS CLRA STAA JMP PORTA,Y,$10 STAT2,$08 LED STAT2,$80,IOK #9 IOK MUTE PROG. No. INCREMENT, UPDATE DISPLAY IF SWITCHED TO TA DON’T INCREMENT NEXT PROG. TOO HIGH ? YES, BACK TO ZERO LED RETUNE ******************************** * * * Decrement key (& knob). * * * ******************************** PDEC2 BRSET BRSET BRSET LDAB BNE JMP STAT4,$20,ALSU2 STAT4,$08,TOG57 PORTD,Y,$20,DMD PSNP PSN1 DOWN ALARM SET-UP ? NO, ALARM DISPLAY ? NO, STANDBY ? NO, PS EDIT MODE ? NO, STEP DOWN AN494 41 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note PDEC BRSET BRSET BRSET BRSET JMP STAT4,$20,ALSU2 STAT4,$08,TOG57 PORTD,Y,$20,DMD STAT,$01,NACS2 DOWN ALARM SET-UP ? NO, ALARM DISPLAY ? NO, STANDBY ? NO, FREQ. MODE ? YES, STEP DOWN ******************************** * * * Alarm dec. (hours/minutes).* * * ******************************** ALSU2 Freescale Semiconductor, Inc... MZ IHRD HZ T5SD DMD NACS2 BRSET TST BEQ DEC BRA LDAA STAA BRA TST BNE LDAA STAA DEC LDAA STAA BSET BCLR RTS STAT4,$40,IHRD AMIN MZ AMIN T5SD #59 AMIN T5SD AOUR HZ #24 AOUR AOUR #80 DIST STAT4,$01 PORTA,Y,$10 LDAB BEQ PSNP CONTD YES, SET-UP HOURS ? NO, MINUTES 10 SECOND TIMEOUT SET DISPLAY TRANSIENT FLAG DEMUTE PS EDIT CHARACTER CHANGE ? ******************************** * * * P-S Edit dec. (ASCII). * * * ******************************** PSN1 MKE20 MKE2E MKE5A MKE7A MKE39 CNTS OUTCH LDX ABX LDAA DECA CMPA BLS CMPA BLS CMPA BLO CMPA BLS CMPA BLO CMPA BLS CMPA BLO CMPA BLS LDAA BRA LDAA BRA LDAA BRA LDAA BRA LDAA STAA LDAA #PSN-1 STAA BSET BCLR RTS DIST STAT4,$01 STAT4,$08 0,X YES DECREMENT ASCII VALUE SPACE LESS OR EQUAL ? NO, . LESS OR EQUAL ? NO, 0 LESS ? NO, 9 LESS OR EQUAL ? NO, A LESS ? NO, Z LESS OR EQUAL ? NO, a LESS ? NO, z LESS OR EQUAL ? MAKE SPACE #$20 MKE7A #$2E MKE20 #$30 MKE2E #$39 CNTS #$41 MKE39 #$5A CNTS #$61 MKE5A #$7A CNTS #$20 CNTS #$2E CNTS #$5A CNTS #$7A CNTS #$39 0,X #80 MAKE . MAKE Z MAKE z MAKE A SET DISPLAY TRANSIENT FLAG NOT ALARM DISPLAY MODE AN494 42 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Code Listing ******************************** * * * Program number decrement. * * * ******************************** CONTD PNM1 Freescale Semiconductor, Inc... SK2P RETUNE RETUNE2 FOK BSET LDAA BRSET DECA BPL LDAA STAA PSHA LDAB JSR PULA BRCLR BCLR LDAA STAA RTS PORTA,Y,$10 LED STAT2,$80,RETUNE SK2P #9 LED MUTE PROG. No. DECREMENT IF SWITCHED TO TA DON’T DECREMENT DECREMENT PROGRAM NUMBER TOO FAR ? SAVE NEW PROGRAM NUMBER #120 WRITE1 CHANGE PROGRAM NUMBER IN NVM STAT4,$80,RETUNE2 STAT4,$80 #9 REARET TA SWITCHED ? YES, MANUAL RETURN FROM TA JSR JSR LDX JSR BCLR BCLR BCLR BCLR RTS DOIT P5170 #64 SKDB PORTA,Y,$10 STAT2,$02 STAT3,$01 STAT,$10 NEW PROGRAM LDAB MUL ADDB STAB ADCA STAA JMP #10 WAIT 100ms DEMUTE KILL ANY PENDING RDS GROUP AND INHIBIT FM PS-NAME CLEARING RE-ENABLE RDS DATA CLEARING #$5C SMEM #$26 SMEM+1 NEW ******************************** * * * Tune to TA (using EEPROM data)* * * ******************************** TASW TPIC TASOK TNP ABTA CLRB ADDB JSR INCB CMPA BNE DECB JSR CMPA BNE SUBB JSR PSHA ANDA BEQ LDAA BRA PULA STAA JSR JMP CMPB BLO PSHA LDAA STAA PULA #10 READ1 FIND PI PION TNP MSB OK ? READ1 PION+1 TNP #12 READ1 LSB OK ? YES, FOUND IT #$80 TASOK #8 ABTA NVM INHIBIT FLAG SET ? NVM INHIBIT MESSAGE SMEM+1 NEWSUB2 NEW #252 TPIC TRY NEXT RECORD #7 REARET AN494 43 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note BCLR RTS STAT4,$80 PI MATCH NOT FOUND, FORGET IT ******************************** * * * Program store/recall. * * * ******************************* Freescale Semiconductor, Inc... DOIT BRSET LDAB MUL BRSET JMP STAT2,$80,TASW #12 STAT5,$40,STORE RECALL ******************************** * * * NVW write, sub-address in X. * * * ******************************** STORE SKTA PSNOK PSOK FINST BCLR BRCLR BSET LDAA JSR LDAA JSR LDAA CMPA BEQ CMPA BNE LDAA JSR LDAA JSR LDAA JSR LDAA JSR LDAA JSR LDAA JSR LDAA JSR LDAA JSR LDAA JSR LDAA BRA SMEM+1,$80 STAT5,$20,SKTA SMEM+1,$80 SMEM+1 WRITE1 SMEM WRITE1 PSN #$A0 PSNOK #$FF PSOK #$FF WRITE1 DISP+10 WRITE1 DISP+11 WRITE1 DISP+12 WRITE1 DISP+13 WRITE1 DISP+14 WRITE1 DISP+15 WRITE1 #$20 WRITE1 #$00 WRITE1 #$00 FINST JRS LDAA JSR LDAA JSR LDAA JSR LDAA JSR LDAA JSR LDAA JSR LDAA JSR LDAA JSR LDAA JSR BCLR RTS WRITE1 PSN+1 WRITE1 PSN+2 WRITE1 PSN+3 WRITE1 PSN+4 WRITE1 PSN+5 WRITE1 PSN+6 WRITE1 PSN+7 WRITE1 PI WRITE1 PI+1 WRITE1 STAT5,$40 TA NVM INHIBIT FLAG SET ? BINARY FREQUENCY MSB BINARY FREQUENCY LSB PS NAME OK ? PERHAPS, TRY FF DUMMY PI CODE PI CODE CLEAR STORE MODE AN494 44 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Code Listing ******************************** * * * NVW read, sub-address in X. * * * ******************************** RECALL BSR JMP NEWSUB NEW NEWSUB JSR STAA BCLR BRCLR BSET JSR CMPA BNE LDAA STAA LDAA STAA JSR STAA JSR STAA JSR STAA JSR STAA JSR STAA JSR STAA JSR STAA JSR STAA RTS READ1 SMEM+1 STAT5,$20 SMEM+1,$80,NEWSUB2 STAT5,$20 READ1 #$FF NOTFF2 #$26 SMEM+1 #$5C SMEM READ1 PSN READ1 PSN+1 READ1 PSN+2 READ1 PSN+3 READ1 PSN+4 READ1 PSN+5 READ1 PSN+6 READ1 PSN+7 Freescale Semiconductor, Inc... NEWSUB2 NOTFF2 $04 $2E ******************************** * * * NVW read & write one byte. * * * ******************************** READ1 JSR LDAA INCB RTS GETAD 0,X WRITE1 LDY BSET BSR JSR BSET DECB #$1000 PPROG,Y,$16 WBYTE DBOUNC PPROG,Y,$02 SET EELAT, ERASE & BYTE ERASE BITS ERASE BYTE WAIT 15 ms SET EELAT TO WRITE BYTE JSR STAA BSET JSR CLR INCB RTS GETAD 0,X PPROG,Y,$01 DBOUNC PPROG,Y LATCH DATA SET EEPGM BIT TO START PROGRAMMING WAIT 15 ms STOP BAND #$B618 GET BAND EEPROM START ADDRESS #1 FMB #122 FM ? #2 FMB MW ? WBYTE GETAD PSHA PSHB JSR LDX TBA CMPA BLS LDAB ABX CMPA BEQ NO, AM AN494 45 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note ABX BRCLR ABX SWB2 * * * FMB BRCLR ABX ABX PULB PULA ABX RTS PORTE,Y,$40,SWB2 NO, SW SECOND BANK ? YES PORTE,Y,$80,FMB SECOND PAIR OF BANKS ? YES Freescale Semiconductor, Inc... ******************************** * * * RDS displays. * * * ******************************** RTDSP BRSET BRSET BRCLR PORTD,Y,$20,SRT STAT5,$02,NOTRT STAT2,$04,NORT STANDBY ? ALREADY RDS DISPLAY ? ALREADY RT DISPLAY ? NOTRT BSET LDAA INCA CMPA BEQ STAA LDAA STAA BSET RTS STAT5,$02 RTDIS SET RDS DISPLAY FLAG YES, MOVE ON #26 NORT RTDIS #100 DIST STAT4,$01 RE-START TRANSIENT TIMEOUT JSR BSET LDAA STAA LDAA STAA RTS CLTR STAT2,$04 #9 DISP1 #1 DISP2 NORT SET RT DISPLAY FLAG ************************************* * * * Increment and decrement routines. * * * ************************************* UP IF TT1 DOWN DF TT2 NEWJ LDXR LDXR2 NFMB BSR INC BNE INC DECB BNE BRA LDXR SMEM TT1 SMEM+1 NO, INCREMENT LSB DID IT WRAP ROUND YES, INCREMENT MSB IF NEWJ ALL DONE ? BSR TST BNE DEC DEC DECB BNE JSR JSR BCLR RTS LDXR SMEM TT2 SMEM+1 SMEM NO, IS LSB ZERO ? IF NOT LEAVE MSD DECREMENT MSB DECREMENT LSB DF NEW P5170 PORTA,Y,$10 ALL DONE ? BRCLR BSET BRA BSET JSR TBA LDAB BRCLR CMPA STAT6,$08,LDXR2 STAT2,$40 NFMB STAT3,$01 BAND AM ? YES, CLEAR PS NAME NO, FM, ENABLE PS NAME CLEARING GET BAND #1 STAT,$02,SRT #3 SINGLE STEP (1,5,10 kHz FOR MW,SW,FM) LARGE STEPS SELECTED ? YES, BAND 3 (SW) ? DEMUTE AN494 46 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Code Listing SRT BEQ LDAB CMPA BNE LDAB BRCLR INCB RTS SRT #5 #2 SRT #9 STAT6,$40,SRT NO, x5 STEP (50 kHz FOR FM) MW ? YES, 9kHz OR SHOULD IT BE 10kHz YES ******************************** * * * TA test. * * * ******************************** Freescale Semiconductor, Inc... TEST AOB NABT SAVE A5SD AISM MSM BRSET LDD STD BRSET LDAA STAA RTS BSET RTS PORTD,Y,$20,AOB #$C5B1 PION STAT4,$04,NABT #1 REARET STANDBY ? CLYDE 1 STAT4,$80 YES, DO IT ******************************** * * * Store key. * * * ******************************** BRCLR STAT4,$08,NAME BRCLR STAT4,$10,NTB2 BRSET STAT4,$20,AISM BSET STAT4,$60 LDAA #80 BRA SDT BRSET STAT4,$40,MSM BCLR STAT4,$20 BRA A5SD BCLR STAT4,$40 BRA A5SD TA SWITCHING ENABLED ? NO, SET RETURN REASON ALARM DISPAY ? YES, ALARM ARMED ? YES, ALREADY SET-UP MODE ? NO, ENTER SET-UP MODE, HOURS YES, SET-UP HOURS ? NO, CANCEL SET-UP YES, MAKE IT MINUTES NAME BRSET BRSET BRSET BSET RTS PORTD,Y,$20,NTB2 STAT,$01,NFM STAT5,$40,ASM STAT5,$40 STANDBY ? NO, FREQUENCY MODE ? YES, STORE MODE ? NO, ENTER STORE MODE ASM LDAA JMP LED DOIT SAVE LDAA BNE JSR INC LDAA CMPA BLS CLR LDAA STAA BSET RTS PSNP SKPCLR CLTR PSNP PSNP #8 NTB3 PSNP #80 DIST STAT4,$01 NFM SKPCLR NTB3 SDT NTB2 NOT FREQUENCY MODE SET UP PS-NAME CHANGE MODE SET DISPLAY TRANSIENT FLAG ******************************************* * * * PROG, the displayed number is added to * * the IF offset, converted to binary and * * stored in SMEM & SMEM+1. * * * * NEW takes binary working frequency * * in SMEM & SMEM+1 converts it to BCD and * * subtracts the IF offset. * * * ******************************************* AN494 47 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note PROG BRSET JSR JSR STAT,$01,NEW IFO ADB JSR BNE JSR LDX LDAA STAA DEX BNE BAND ONE ADD #5 RQ-1,X RQ,X LPP MOVE ALL DIGITS IN Q DOWN ONE PLACE TO DEVIDE BY 10 (Q < Q/5) ONE JSR BCON CONVERT Q TO BINARY NEW JSR DCON CONVERT TO BCD IN Q JSR BNE STX LDX JSR LDX STX LDX JSR LDX JSR BAND STIF NUM1 #RP ADD #RP NUM1 #RQ ADD #RQ ADD JSR BSET JMP IFO STAT,$04 SUB Freescale Semiconductor, Inc... LPP STIF STATION MODE ? P < IF OFFSET Q < FREQ + IF BAND 3 (SW) ? YES, DIVIDE BY 5, Q < 2 X (FREQ + IF) BAND 3 (SW) ? YES P < 2Q Q < 3Q Q < 5Q P < IF OFFSET Q < (RATIO X STEP) -IF ******************************************* * * * The IF offset is selected according to * * the required band and placed in "RP." * * * ******************************************* IPO BSR BRSET CMPB BHI LDAB LDAA MUL LDX ABX LDY LDAA STAA INX INY CPY BLO LDY LDX STX LDX STX RTS BAND PORTA,Y,$04,NOTN #1 NOTN #4 #6 IFS FCB FCB FCB FCB FCB 0,0,1,0,7,0 0,0,1,0,7,0 0,0,0,4,5,5 0,1,0,7,0,0 9,9,8,9,3,0 10.70 10.70 455 10.70 –10.70 BAND LDAB ANDB LDX STX CMPB RTS PORTA,Y #$03 #RQ NUM2 #3 GET BAND NOTN LP6 FIND BAND NEGATIVE FM IF ? YES BUT IS IT FM ? YES, FIFTH IS FROM TABLE TIMES 6 #1FS #RP 0,X 0,Y TRANSFER INTO RP #RP+6 LP6 #$1000 #RP NUM2 #RQ NUM1 DONE ? RE-INITIALISE Y SET-UP POINTERS MHz MHz kHz MHz MHz FM OSC HIGH FM OSC HIGH SW/MW SW (EXT/5 FOR 5157) FM OSC LOW BAND 3 (SW, /5) ? AN494 48 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Code Listing ******************************** * * * Mode change & clear routines.* * * ******************************** MODE SKIP Freescale Semiconductor, Inc... SK SKSM NNTR CLEAR CLAL SM SPCC KHZ CLP CLQ CLRAS CR CLTR CLTR2 BRSET JSR JSR BRCLR BCLR RTS PORTD,Y,$20,CLP CLTR PROG STAT,$01,SK STAT,$01 STANDBY ? BCLR BRCLR BSET JSR JSR LDX JSR BCLR BCLR BCLR RTS BSET BCLR RTS STAT5,$40 STAT5,$10,NNTR PORTA,Y,$10 DBNC P5170 #64 SKDB PORTA,Y,$10 STAT2,$02 STAT5,$10 FREQ. MODE, CLEAR STORE MODE NEW FREQUENCY ENTERED ? YES, MUTE WAIT 15ms STAT,$01 STAT5,$40 NO, RETURN TO STATION MODE CANCEL STORE MODE BRSET BRSET BSET BSR LDAA BEQ JSR JSR BRSET BSET RTS BCLR RTS PORTD,Y,$20,CLP STAT,$01,SM STAT5,$10 CLQ PSNP SPCC PSC CLTR STAT,$02,KHZ STAT,$02 STANDBY ? NO, STATION MODE ? FREQUENCY CHANGED NO, CLEAR Q STAT,$02 1 (MW), 10 (FM) kHz STEPS LDX LDAA STAA CLR INX DEC BNE RTS #RQ #06 COUNT 0,X CLEAR RQ CLEAR 6 BYTES STARTING AT X COUNT CR DONE ? BCLR BCLR CLR BCLR BCLR CLR RTS STAT4,$01 STAT2,$04 RTDIS STAT4,$28 STAT5,$06 PSNP SEND DISPLAYED FREQUENCY FREQUENCY MODE ? NO, SET TO FREQUENCY MODE WAIT 100ms DE-MUTE AND KILL ANY PENDING RDS GROUP CLEAR RETUNE FLAG CLEAR DISPLAY TRANSIENTS 9 (MW), 50 (FM) kHz STEPS CLEAR DISPLAY TRANSIENT FLAG CANCEL RT DISPLAY NOT ALARM (DISPLAY OR SET-UP) NOT RT OR SLEEP DISPLAY NOT PS-EDIT ******************************************** * * * BCD to binary conversion. No, in "RQ" is * * converted to binary in SMEM & SMEM+1. * * * ******************************************** BCON L2 CLR CLR LDX LDAA LSLA STAA ROL LDAA STAA SMEM SMEM+1 #0 SMEM W1 SMEM+1 SMEM+1 W2 CLEAR WORKING FREQUENCY LOCATIONS LS BYTE 2xLSB SAVE 2xLSB 2xMS BYTE SAVE 2xMSB AN494 49 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Freescale Semiconductor, Inc... Application Note LDAA LSLA ROL LSLA ROL ADDA STAA LDAA ADCA STAA ADCA STAA INX LDAA ADDA STAA LDAA ADCA STAA CPX BNE RTS W1 2xLSB 4xLSB 4xMSB 8xLSB 8xMSB 10xLSB SMEM+1 SMEM+1 W1 SMEM SMEM+1 W2 SMEM+1 W2 SMEM+1 10xMSB FETCH NEXT DIGIT AND (CLRA CLEARS THE C BIT) ADD IT TO WORKING FREQUENCY DONE ? RQ,X SMEM SMEM #0 SMEM+1 SMEM+1 #5 L2 ******************************** * * * Clear NVM - not used. * * * ******************************** CLRNVW CLOP CLR LDAA LDAB JSR INC BNE CLRA LDAB JMP COUNT #$FF COUNT WRITE1 COUNT CLOP #120 WRITE1 CLEAR MAX. PROG. No. ******************************************** * * * Addition and subtraction of BCD numbers. * * * ******************************************** SUB COM2 COMP LOOP3 ADD AD LOOP STX LDX LDAB LDAA SUBA STAA DEX DECB BNE CLR INC BRA W5 NUM2 #$06 #$09 5,X 5,X CLR STX LDAB LDX STX LDX STX LDX LDAA DEX STX LDX ADDA DEX STX ADDA CLR BSR CARRY W5 #$06 NUM1 W3 NUM2 W4 W3 5,X LOOP3 CARRY CARRY AD ANSWER POINTER 9S COMPLIMENT SECOND NUMBER SUBTRACT FROM 9 AND PUT IT BACK SET CARRY TO ONE BEFORE ADDING ADD FIRST NUMBER ANSWER POINTER 1st No. POINTER 2nd No. POINTER W3 W4 5,X ADD W4 CARRY CARRY ADJ SET ON ADDITION OVERFLOW OR POS. RESULT SUBTRACTION DECIMAL ADJUST AN494 50 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Code Listing AJ Freescale Semiconductor, Inc... ADJ LDX STAA DEX STX DECB BNE RTS W5 5,X LOOP DONE ? SUBA INC CMPA BHS RTS #10 CARRY #10 AJ YES, SUBTRACT 10 AND RECORD CARRY SAVE ANSWER W5 10 OR MORE ? NO ****************************************** * * * Current binary divide ratio in SMEM & * * SMEM+1 is converted to decimal in RQ. * * * ****************************************** DCON DCON2 LOOP2 NXT LDAA STAA LDAA STAA LDX STX JSR INC JSR LDAA STAA LSR ROR BCC LDX STX BSR LDX STX BSR DEC BNE RTS SMEM+1 W2 SMEM W1 #RR NUM1 CLRAS RR+5 CLQ #14 W6 W2 W1 NXT #RQ NUM2 ADD #RR NUM2 ADD W6 LOOP2 TRANSFER CURRENT FREQUENCY DIVIDE RATIO INTO WORKING AREA CLEAR RR RR <- 1 CLEAR RQ 14 BITS TO CONVERT MOVE OUT FIRST (LS) BIT ZERO ONE, ADD CURRENT VALUE OF RR ADD RR TO ITSELF ALL DONE ? ******************************** * * * Delay (X x 1.5mS). * * * ******************************** DBNC DBOUNC SKDB DLP DLOOP ABO LDX BRA LDX STX LDX BRN BRN DEX BNE DEC BNE RTS #100 SKDB #10 W6 #$FF " " 150mS APPROX 15mS WITH A 8.388 MHz XTAL X x 1.5mS PAUSE 256X12 CYCLES DLOOP W6+1 DLP ******************************************* * * * Serial output routine to the MC145170. * * * ******************************************* P5170 BCLR BCLR LDAA BSR BSET PORTB,Y,$01 PORTB,Y,$10 #0 SQU8I PORTB,Y,$10 CLOCK LOW LE LOW CLEAR CONTROL REGISTER LATCH IT AN494 51 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Freescale Semiconductor, Inc... Application Note BCLR LDAA ANDA BSR LDAA BSR BSET PORTB,Y,$10 SMEM+1 #$7F SQU8I SMEM SQU8I PORTB,Y,$10 LE LOW SEND MSBYTE AND LSBYTE OF NEW FREQUENCY LATCH IT BCLR LDAA BSR LDAA BSR BSET PORTB,Y,$10 #$03 SQU7I #$20 SQU8I PORTB,Y,$10 LE LOW SEND REFERENCE DIVIDE RATIO 800 = 8MHz/10kHz LATCH IT ****************************************** * * * Serial output routine to the MC145157. * * * * ****************************************** P5157 LDAA LSLA STAA LDAA ROLA BSR LDAA BSR BSET BCLR LDAA BSR LDAA BSR BSET BCLR RTS SMEM W4 SMEM+1 SQU7 W4 SQU8 PORTB,Y,$08 PORTB,Y,$08 #$4E SQU7 #$21 SQU8 PORTB,Y,$08 PORTB,Y,$08 TRANSFER SMEM AND MEM+1 TO TEMPORARY LOCATIONS AND MOVE UP ONE BIT TO INCLUDE THE 5157 CONTROL BIT. SEND MSBYTE (7 BITS) AND LSBYTE OF NEW FREQUENCY LATCH IT SEND 15 BIT (14+1) REFERENCE DIVIDE RATIO LATCH IT ALL LOW (5157/70 SWITCHED OFF) ************************************** * * * Subroutines for the MC145157/170. * * * ************************************** SQU8I SQU7I S1I S21 SQU8 SQU7 S1 S2 LDAB BRA LSLA LDAB LSLA BCC BSET BSET BCLR BCLR DECB BNE RTS #8 S1I SEND 8 BITS S1I ANY MORE ? LDAB BRA LSLA LDAB LSLA BCC BSET BCLR BSET BCLR DECB BNE RTS #8 S1 SEND 8 BITS #7 S2I PORTB,Y,$02 PORTB,Y,$01 PORTB,Y,$01 PORTB,Y,$02 #7 S2 PORTB,Y,$02 PORTB,Y,$01 PORTB,Y,$01 PORTB,Y,$02 S1 MOVE OUT MS BIT AND SEND OTHER 7 MOVE I BIT INTO "C" ZERO ? NO CLOCK IT MOVE OUT MS BIT AND SEND OTHER 7 MOVE 1 BIT INTO "C" ZERO ? NO CLOCK IT ANY MORE ? AN494 52 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Code Listing ******************************** * * * Toggle 9/10 kHz step (MW). * * * ******************************** T910 CBH BRSET BSET RTS BCLR RTS STAT6,$40,CBH STAT6,$40 STAT6,$40 **************************************************************************** Freescale Semiconductor, Inc... * * LINK batch files (RLE.BAT & RDE.LD) and PCBUG11 Vectors. * * * * ILD11 RADE.O FNCE.O RDSE.O -MKUF E32.MAP -G RDE -O RDE.OUT * * IHEX RDE.OUT -O RDE.0 * * TYPE E32.MAP * * * * section .RAM1 BSS origin 0x0000 * * section .RAM2 BSS origin 0x0100 * * section .RAM3 BSS origin 0x0200 E32 * * section .ROM1 origin 0xD000 $9000 * * section .ROM2 origin 0xE000 $9c00 * * section .ROM3 origin 0xF000 $A000 * * section .VECT origin 0xBFC1 * * section .VECT2 origin 0xFFD6 ($FFD6) * * * **************************************************************************** * SECTION .VECT * * * * * * * * * * * * * * * * * * * * * JMP JMP JMP JMP JMP JMP JMP JMP JMP JMP JMP JMP JMP JMP JMP JMP JMP JMP JMP JMP JMP * * * ******************************** * * * MC68HC11E32 Vectors. * * * ******************************** * SECTION ORG .VECT2 $FFD6 FDB FDB FDB FDB FDB FDB FDB FDB FDB FDB FDB FDB START START START START START START START START START START START START START START START START START START START START START START START START START TINTB SDATA SHAFTX START START START START START SCI SPI PULSE ACCUMULATOR EDGE " " OVER TIMER OVER " IC4/OC5 " OC4 " OC3 " OC2 " OC1 " IC3 " IC2 " IC1 RTI IRQ NOT USED, XIRQ USED BY PCbug11 SWI ILLEGAL OP CODE COP CLOCK MONITOR RESET SCI SPI PULSE " TIMER " " " " " " " ACCUMULATOR EDGE " OVER OVER IC4/OC5 OC4 OC3 OC2 OC1 IC3 IC2 AN494 53 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note FDB FDB FDB FDB FDB FDB FDB FDB FDB START TINTB SDATA SHAFTX START START START START START " IC1 RTI IRQ XIRQ SWI ILLEGAL OP CODE COP CLOCK MONITOR RESET END Freescale Semiconductor, Inc... 174) 256) 109) 2889) 42) .RAM1 .RAM2 .RAM3 .ROM1 .VECT2 A5SD A7 ABO ABO3 ABOA ABTA AD ADD ADJ ADON AGS AISM AJ ALARM ALOF ALRON ALSU1 ALSU2 AMIN ANTI AOB AOUR ARI ASM BAND BCON BCTO BD3 BIT BMJD BTO CARRY CBCD I CBH CE6 CG6 CHE CLAL CLEAR CLOCK I CLOOP CLOP CLP CLQ CLRAS CLREON I CLRNVM 1 2 3 4 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 1 4 4 1 4 4 4 4 1 4 1 1 4 1 0 4 4 4 4 4 4 0 4 4 4 4 4 0 4 Symbol 00000000 | 00000000 | 00000000 | 00000000 | 00000000 | 00000847 | 00000524 | 00000aa7 | 00000470 | 000003a3 | 0000065c | 00000a24 | 00000a1f | 00000a53 | 00000393 | 0000044e | 0000084b | 00000a4e | 00000381 | 0000038e | 000003be | 000004a5 | 00000569 | 00000072 | 00000191 | 00000833 | 00000073 | 00000220 | 0000086a | 00000926 | 000009b6 | 000000ac | 000001ec | 00000068 | 00000000 | 00000201 | 00000099 | 00000000 | 00000b45 | 000001ec | 000001c8 | 000001e6 | 0000097b | 0000096f | 00000000 | 0000005a | 000009f5 | 00000992 | 00000993 | 00000996 | 00000000 | 000009f2 | Section synopsis .RAM1 .RAM2 .RAM3 .ROM1 .VECT2 table CONTD CONTI COUNT CPSL CR CTAB DAT DBNC DBOUNC DCON DCON2 DECS DEL500 DF DI DIG2 DIGIT DISP DISP1 DISP2 DISPP DIST DLOOP DLP DMD DMI DNT DNT2 DOIT DOM DOW DOWN DR1 E6L EON EXIT FINST FLN FMB FOK FULON GETAD GON2 GOON GOON2 GOON3 GROUP H2L HIGH HTOH HZ IDLE E 4 4 1 4 4 4 1 4 4 4 4 4 4 4 1 1 4 3 1 1 3 1 4 4 4 4 4 4 4 1 1 4 4 4 2 4 4 4 4 4 4 4 4 4 4 4 1 4 4 4 4 4 000005df 00000529 0000009a 000003cc 0000099a 00000325 0000004b 00000a8e 00000a93 00000a58 00000a60 0000040d 00000471 000007e0 000000a4 00000098 00000426 00000000 00000074 00000075 00000010 00000047 00000a9b 00000a98 00000594 000004d2 000002f4 000002ed 00000663 00000044 00000046 000007de 00000466 000001fa 00000000 000002ab 000006fb 00000122 0000079b 0000061d 0000010f 00000780 000002c8 000002e4 000002d0 000002de 00000057 00000032 000003e9 000004c4 00000586 000000ac | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | INSLP IOK IOOK IRQ ITMP1 KBD KCLC KEY KEY1 KEYP KEYP2 KHZ KOUNT L1 L2 L5 L6 LAST LDRX LDXR2 LED LEV LOOP LOOP2 LOOP3 LP6 LPP M8 MAK20 MAK2E MAK30 MAK41 MAK61 MIN MJD MJDAT MKE20 MKE2E MKE39 MKE5A MKE7A MNTH MOD MODE MSH MSM MZ NABT NACS NACS2 NAME NDU I I 4 4 4 4 1 4 4 1 4 4 4 4 1 4 4 4 4 4 4 4 1 1 4 4 4 4 4 4 4 4 4 4 4 1 1 0 4 4 4 4 4 1 0 4 4 4 4 4 4 4 4 4 000003fe 0000053c 0000022e 00000006 00000069 0000026f 000002f3 00000096 00000279 000002f5 000002f7 0000098f 00000097 00000298 000009bf 000001b8 000001d6 0000037d 000007f9 00000802 0000009f 00000067 00000a2e 00000a72 00000a0d 000008eb 0000089f 00000079 000004fe 00000502 00000506 0000050a 0000050e 00000070 00000030 00000000 000005c0 000005c4 000005d0 000005c8 000005cc 00000042 00000000 00000933 00000238 00000854 00000577 00000834 000004d3 00000595 00000859 000000db | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | NNTR NO2D NOPS NORT NOTCH NOTFF2 NOTN NOTRT NOTSNZ NRDSP NRML NS1 NSRO NT1 NT2 NT2J NTB2 NTB3 NUM1 NUM2 NWA NWWS NXT OK6 ONAG ONE ONOFF OUR OUTCH P P5157 P5170 PDEC PDEC2 PI PIN PINC PINC2 PINOK1 PION PJ PNM1 PROC PROG PSC PSN PSN0 PSN1 PSNOK PSNP PSOK PTY 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 1 1 4 4 4 4 4 4 4 1 4 1 4 4 4 4 1 1 4 4 4 1 4 4 0 4 4 3 4 4 4 1 4 1 00000968 000000c6 000000d1 000007c0 000002bc 00000723 000008e0 000007ac 000000e0 0000019b 000002c0 000003ea 00000194 00000165 0000017b 000000e4 00000889 00000882 0000009b 0000009d 000000f1 00000173 00000a81 0000020b 00000101 000008a6 000003a4 00000071 000005d6 00000015 00000ada 00000aa8 00000555 00000541 00000061 00000065 00000491 0000047d 00000161 00000063 0000031d 000005e9 00000000 0000088a 000003c7 00000020 000004d7 00000599 00000690 0000004a 000006c7 0000005f | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | RECALL RETUNE RETUNE2 RJ RKEY RP RPT RQ RR RT RTDIS RTDSP S1 S1I S2 S2I SAVE SCHAN SCNT SDATA I SDT SEC SEM SHAFT E SHAFTX SHIFT SK SK2P SKDB SKIP SKP SKPCLR SKSM SKTA SLEEP SLEP SLEPT SLPTOK SM SMEM SODM SOK SPCC SQU7 SQU7I SQU8 SQU8I SRT START STAT STAT2 STAT3 4 4 4 4 4 1 4 1 1 3 1 4 4 4 4 4 4 1 1 0 4 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 1 4 4 1 4 4 4 4 4 4 4 4 4 1 1 1 00000702 000005f0 00000603 0000030a 000002ea 0000007c 00000309 00000076 00000082 00000028 000000a3 0000079f 00000b26 00000b08 00000b2d 00000b0f 00000838 000000a5 000000ad 00000000 00000884 0000006f 00000257 0000024d 0000025e 0000044a 00000946 000005ee 00000a96 0000093e 0000045c 00000876 00000964 0000067b 000003f6 00000400 00000048 00000415 0000097d 000000a0 000003b2 00000148 00000984 00000b23 00000b05 00000b1f 00000b01 00000820 00000009 000000a6 000000a7 000000a8 AN494 54 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Code Listing CLTR CLTR2 CNTB CNTS COM2 COMP CONF 4 4 4 4 4 4 1 000009a3 000009a6 00000510 000005d2 00000a09 00000a0b 0000006c | | | | | | | IDLJ IF IFO IFS IHR IHRD INITD 4 4 1 4 4 4 4 4 4 4 00000a07 0000079b 0000006a 000004c7 00000589 00000b3d 000003e6 0000064c 0000062b 0000022a | | | | | | | | | TATP TBH TEM TEST TFCC TH32 TH8 TINTB TMP I I I 4 4 4 4 4 4 0 0000023c 000007d1 000008d3 00000908 000004b9 0000057d 00000000 | | | | | | | NEW E NEWJ NEWSUB NEWSUB2 NFM NFMB NNT2 4 4 4 4 4 4 4 000008a9 000007ee 00000707 00000716 0000086f 00000805 000000e7 | | | | | | | PTYCMP Q R RCLP RDSTO READ1 REARET 1 1 1 4 1 4 1 00000060 00000003 00000027 0000023f 00000049 00000756 000000a2 | | | | | | | STAT4 STAT5 STAT6 STIF STORE STR STRST 1 1 1 4 4 4 4 000000a9 000000aa 000000ab 000008ca 00000671 00000405 00000000 4 4 4 4 0 1 1 0 1 0000022a 000000be 0000025a 00000821 00000000 0000006d 0000006e 00000000 0000001e | | | | | | | | | TMPGRP TMQ TMRB TNP TOG57 TOG57J TOOH TPEN TPIC 1 1 4 4 4 4 4 4 4 0000004f 0000000c 00000003 00000655 00000517 00000495 000004b4 000003d5 0000062c | | | | | | | | | TPOF TPOK TT1 TT2 UDCNT UP W1 W2 W3 4 4 4 4 4 4 1 1 1 000003f2 00000155 000007d9 000007e8 00000399 000007cf 00000088 0000008a 0000008c | | | | | | | | | W4 W5 W6 W7 WAIT WBYTE WRITE1 XEM YEM 1 1 1 1 0 4 4 4 4 0000008e 00000090 00000092 00000094 00000000 0000076f 0000075d 00000268 0000026b I Freescale Semiconductor, Inc... SUB SWB2 SYN T5S T5SD T910 TAEH TASOK TASW TATP E AN494 55 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. N O N - D I S C L O S U R E Freescale Semiconductor, Inc... A G R E E M E N T R E Q U I R E D Application Note How to Reach Us: Home Page: www.freescale.com E-mail: [email protected] USA/Europe or Locations Not Listed: Freescale Semiconductor Technical Information Center, CH370 1300 N. Alma School Road Chandler, Arizona 85224 +1-800-521-6274 or +1-480-768-2130 [email protected] Europe, Middle East, and Africa: Freescale Halbleiter Deutschland GmbH Technical Information Center Schatzbogen 7 81829 Muenchen, Germany +44 1296 380 456 (English) +46 8 52200080 (English) +49 89 92103 559 (German) +33 1 69 35 48 48 (French) [email protected] Japan: Freescale Semiconductor Japan Ltd. Headquarters ARCO Tower 15F 1-8-1, Shimo-Meguro, Meguro-ku, Tokyo 153-0064 Japan 0120 191014 or +81 3 5437 9125 [email protected] Asia/Pacific: Freescale Semiconductor Hong Kong Ltd. Technical Information Center 2 Dai King Street Tai Po Industrial Estate Tai Po, N.T., Hong Kong +800 2666 8080 [email protected] For Literature Requests Only: Freescale Semiconductor Literature Distribution Center P.O. Box 5405 Denver, Colorado 80217 1-800-441-2447 or 303-675-2140 Fax: 303-675-2150 [email protected] Information in this document is provided solely to enable system and software implementers to use Freescale Semiconductor products. There are no express or implied copyright licenses granted hereunder to design or fabricate any integrated circuits or integrated circuits based on the information in this document. Freescale Semiconductor reserves the right to make changes without further notice to any products herein. Freescale Semiconductor makes no warranty, representation or guarantee regarding the suitability of its products for any particular purpose, nor does Freescale Semiconductor assume any liability arising out of the application or use of any product or circuit, and specifically disclaims any and all liability, including without limitation consequential or incidental damages. “Typical” parameters which may be provided in Freescale Semiconductor data sheets and/or specifications can and do vary in different applications and actual performance may vary over time. All operating parameters, including “Typicals” must be validated for each customer application by customer’s technical experts. Freescale Semiconductor does not convey any license under its patent rights nor the rights of others. Freescale Semiconductor products are not designed, intended, or authorized for use as components in systems intended for surgical implant into the body, or other applications intended to support or sustain life, or for any other application in which the failure of the Freescale Semiconductor product could create a situation where personal injury or death may occur. Should Buyer purchase or use Freescale Semiconductor products for any such unintended or unauthorized application, Buyer shall indemnify and hold Freescale Semiconductor and its officers, employees, subsidiaries, affiliates, and distributors harmless against all claims, costs, damages, and expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury or death associated with such unintended or unauthorized use, even if such claim alleges that Freescale Semiconductor was negligent regarding the design or manufacture of the part. For More Information On This Product, Go to: www.freescale.com