Introduction: How to Make an SPI Digital ISDN Telephone Handset

About: GreenPAK™ is a broad family of cost-effective NVM programmable devices that enable innovators to integrate many system functions into a single custom circuit.

A handset is the part of a landline telephone that contains a speaker to receive audio, a microphone to transmit audio, and circuitry to interface with the base station. It can also be in the form of a headset.

Integrated Services Digital Network (ISDN) is a set of communication standards for simultaneous digital transmission of voice, video, data, and other network services over the traditional circuits of the public switched telephone network. The bearer channel (B) is a standard 64 kbit/s voice channel of 8 bits sampled at 8 kHz.

This Instructable will present the design of an SPI digital ISDN telephone handset using two SLG46140V GreenPAK™ IC's. The designed telephone handset contains a speaker and a microphone and can transmit and receive audio over the SPI bus to/from the base unit at 64 kbit/s (8-bit audio sampled at 8 kHz sampling rate).

The following sections will show:

● the SPI digital telephone handset circuit;

● the SLG46140V GreenPAK telephone handset design in detail;

● how to drive the handset over SPI.

Below we described steps needed to understand how the solution has been programmed to create a telephone handset. However, if you just want to get the result of programming, download GreenPAK software to view the already completed GreenPAK Design File. Plug the GreenPAK Development Kit to your computer and hit the program to design the solution.

Step 1: SPI Digital Telephone Handset Circuit

Figure 2 shows the handset circuit. The capacitive microphone is connected between GND and a 10 k pullup resistor to 5 V. This fills the microphone capacitor with charge proportional to its capacitance. Sound vibrations make the capacitance fluctuate which in turn results in voltage fluctuations on the positive microphone terminal pin. The sound modulated voltage gets AC coupled and transmitted across the 1 uF capacitor to the PGA (+) - input on PIN6 of the left SLG46140V GreenPAK device. The two 10 k resistors connected to PIN6 are a weak voltage divider dividing the 1200 mV VREF on PIN3 to 600 mV to center the input to the middle of the PGA/ADC range (0~1200 mV). PIN7 is the PGA (-) - input and is just centered at 600 mV by two 10 k resistors dividing VREF. That way we have a ZERO point from which we can use the differential PGA amplification (16x) to amplify the microphone signal around the 600 mV ZERO point. Without the differential PGA mode, 16x amplification would result in amplifying also the 600 mV offset, saturating the PGA to the maximum value, and losing the microphone signal.

The microphone signal gets amplified, digitized, and transmitted over the SPI bus to the base unit.

From the base unit, we receive the digital voice signal of the other party over the SPI bus, and inside the right SLG46140V GreenPAK device, it gets converted to a PWM signal (0/5 V, 106 kHz) suitable for the n-MOS driver of the speaker. The n-MOS driver modulates the +5 V voltage on the speaker with the PWM voice signal, creating audible sound on the speaker to hear the other party. The sound is RC filtered for improved clarity.

Figure 3 shows a simple method to generate the PWM pulse train corresponding to a given signal is by using the intersective PWM method: the signal (here the red sine wave) is compared with a sawtooth waveform (blue). When the latter is less than the former, the PWM signal (bottom) is in high state (1). Otherwise it is in the low state (0). We do all this digitally, with a counter for the sawtooth, and an updating SPI voice value for the signal.

Step 2: GreenPAK Design Schematics

The schematic of the GreenPAK design #1 – SPI ADC is shown in Figure 4.

The schematic of the GreenPAK design #2 – SPI DAC is shown in Figure 5.

Step 3: GreenPAK Design #1 – SPI ADC

The analog microphone signal gets differentially amplified in the PGA (x16) and then gets fed into the ADC to be digitized. The digitized signal gets transmitted over the MISO line (PIN12) while the SPI master provides the SCLK (PIN11) and sample framing every 16 bits thru the nCSB (PIN13). The samples happen to occupy bits [9:2] out of [15:0] and are UNSIGNED WITH OFFSET (0x0000~0x03FC) as can be seen from the logic analyzer screenshot for the ADC value saturated to the maximum value - Figure 6.

The C source code snippet below shows how to read a word of SPI data and convert the sample to from UNSIGNED WITH OFFSET (0x0000~0x03FC) to SIGNED value (0xFE00~0x01FC).

/*AudioInput.c*******************************************************BEGIN**SNIPPET***

NCSB_ASSERT;

AudioSample = ((int16_t)SPI_TransferByte(0))<<8;

AudioSample |= ((int16_t)SPI_TransferByte(0))&0x00FF;

NCSB_DEASSERT;

AudioSample >>= 2;

AudioSample = (AudioSample&0x80)?(0x007F&AudioSample):(0xFF80|AudioSample);

AudioSample <<= 2;

**AudioInput.c**************************************************************END**SNIPP ET**/

Step 4: GreenPAK Design #2 – SPI DAC

The digitized signal gets transmitted over the MOSI line (PIN12) while the SPI master provides the SCLK (PIN11) and sample framing every 16 bits thru nCSB (PIN13). Since we are reading only 8 bits [15:8] it is OK to transmit the sample twice every nCSB frame. The C source code snippet below shows how to write a word of SPI data.

/*AudioOutput.c******************************************************BEGIN**SNIPPET***

NCSB_ASSERT;

SPI_TransferByte(MixedSample_8Bit);

SPI_TransferByte(MixedSample_8Bit);

NCSB_DEASSERT;

**AudioOutput.c*************************************************************END**SNIPP ET**/

The digitized audio sample then gets compared inside DCMP0/PWM0 to a digital “sawtooth signal” from CNT2 counting (0 ~ 255) with an overflow period of 9.3945 uS, (or 106 kHz). This results in a PWM signal going to PIN3 suitable for driving a small speaker thru an n-MOS driver.

Step 5: GreenPAK Design Pinout

The Design consists of two GreenPAK SLG46140V ICs. The #1 - ADC Pinout is shown in Table 1 and Figure 7. The #2 - DAC Pinout is shown in Table 2 and Figure 8.

Step 6: Test Results

The microphone signal is sampled at 8-bit resolution and 8kHz sampling frequency, outputting an uncompressed digital audio signal of 64 kbit/s. With the use of an Atmel AT90USB1286 USB devkit and the LUFAlib (Lightweight USB Framework for AVRs), we have compiled an Audio Input Device to feed the signal into GNUradio software for Fourier Analysis. Figure 9 shows the microphone signal frequency response to uniform white noise. This would be a good approximation of the microphone system transfer function. Since it has a wide uniform gain area it is more quantitative proof of its ability to transfer audible sound to the base unit.

The speaker system was tested as well. With the use of an Atmel AT90USB1286 USB devkit and the LUFAlib (Lightweight USB Framework for AVRs), we have compiled an AudioOutput Device to feed the digital signal from a PC into our GreenPAK DAC driving the n-MOS driver, and subsequently the speaker. The audio quality had distinguishable speech/voice, suitable for a handset of a telephone.

Conclusion and Results Discussion

The Design of an SPI Digital ISDN Telephone Handset was presented. Through two GreenPAK designs on the SLG46140V, we have successfully implemented a light-weight cost-effective solution. The design successfully encodes/decodes a microphone/speaker audio signal with 8-bit resolution at 8 kHz sample rate resulting in 64 kbit/s uncompressed audio suitable for a telephone quality voice calls over the ISDN network. We have used two IC's in the design since the ADC/SPI and SPI/DAC components cannot be used simultaneously in one IC. The SPI component is not "Full-Duplex", so in a single device, we have to choose between the SPI P2S (Parallel 2 Serial) and the SPI S2P (Serial 2 Parallel) mode using the SPI MISO pin in the first case and the SPI MOSI pin in the second case. This should not be a problem because the GreenPAK IC's are compact and still cost-effective even when used in pairs or more per design.

Step 7: Appendix a RC Filter Calculation

1. Since the speaker is 32 ohm, we will have the same order of magnitude R to maximize power.

2. We want a cutoff frequency of just under 4 kHz. (8 kHz/2)

3. Let R be ~ 47 ohm ...

4. That means that C should be 1 / 4 kHz / 2 / Pi / 47 ohm = ~ 1 uF …

5. ...for a cutoff frequency of 1 / 2 / Pi / R / C = ~ 3.4 kHz