Welcome to the tutorial for the MPLAB Starter Kit for dspic DSCs Welcome to this tutorial on Microchip s MPLAB Starter Kit for dspic Digital Signal Controllers, or DSCs. The starter kit is an all-in-one tool that introduces you to the speech and audio processing capabilities of Microchip s dspic DSCs. This starter kit makes it easy for you to get a jump start on using dspic DSCs in your own applications. 1
Inside the Starter Kit Take a look inside the MPLAB Starter Kit for dspic DSCs to find important components. 2
Inside the Starter Kit INSTALLATION CD Included are an quick-and-easy single-step installation software disc, 3
Inside the Starter Kit INSTALLATION CD STARTER KIT BOARD the starter kit board 4
Inside the Starter Kit INSTALLATION CD USB CABLE STARTER KIT BOARD and a USB Mini-B cable for hardware connection. This cable is the debug interface to Microchip s MPLAB IDE and provides power to the starter kit board. 5
Installing the Starter Kit Install the software Connect the board to the PC with the USB cable Read the User s Guide Then you can: Experience the Demo Speech Application Start developing speech applications To install the starter kit software, insert the CD and follow the instructions. The installer program will install MPLAB IDE, a student version of the C30 C compiler, demo applications and the starter kit documentation. After the software installation is complete, plug the starter kit board into the USB port of the PC. The entire installation procedure is described in detail in the MPLAB Starter Kit for dspic DSCs User s Guide which is available on the CD. You are now ready to experience the included demo or start developing your own speech and audio processing application. Note that the starter kit does not require an external debugger since it already contains the required hardware on the board. A Speech Record and Playback Demo application is pre-programmed on the dspic DSC. This demo application uses the ITU-T G.711 algorithm to encode and decode speech data. You can also test other algorithms such as SPEEX and G.726A which are offered by Microchip. You will need a headphone and a microphone for the demo application. These are not included in the starter kit. 6
The Starter Kit Board Let s take a closer look at the starter kit hardware. The Board has three functional sections. 7
The Starter Kit Board DEBUG / PROGRAM SECTION The debug and programmer section interfaces with the USB port on the PC and provides debug and programming capability. 8
The Starter Kit Board dspic DSC SECTION The dspic section hosts the dspic DSC. 9
The Starter Kit Board AUDIO SECTION The Audio section contains the circuits that are required for record, playback and capture of audio signals. 10
The Starter Kit Board The board comes equipped with: A dspic33fj256gp506 16-bit digital signal controller with 256 Kilo Bytes of flash memory, 16 Kilo Bytes of RAM and a comprehensive set of peripherals. This device serves as the computational device on the board. 11
The Starter Kit Board A PIC18F67J50 8-bit microcontroller which serves as the debugger and programmer for the dspic device. It also provides the full-speed USB interface required to connect the board to the PC. 12
The Starter Kit Board A + 3.3V regulator that powers the starter kit board via USB 13
The Starter Kit Board A 4 Mega Bit Serial Flash memory device to store speech and other data 14
The Starter Kit Board An Audio Codec for high fidelity speech and audio applications. This codec is capable of processing up to 32-bit audio data at a sample rate of up to 48 Kilo Hertz. 15
The Starter Kit Board Analog Filters for implementing low-cost speech playback using the pulse width modulation technique. 16
The Starter Kit Board Front End Microphone processing circuits consisting of a pre-amplifier and an anti-aliasing filter. The pre-amplifier features an adjustable gain for adjusting the microphone sensitivity. The anti-aliasing filter provides the required band limiting of the microphone signal before it is processed by the 12 bit ADC on the dspic33f device. 17
The Starter Kit Board A 100 milliwatt Headphone amplifier provides the required amplification of the audio signal for driving a headphone. The volume of the amplifier can be controlled by the dspic33f device. 18
The Starter Kit Board Three user-defined indicator L.E.D.s and two switches which are available for application use. 19
The Starter Kit Board A USB connection between the board and the PC. 20
The Starter Kit Board A connection to a headphone, 21
The Starter Kit Board And a connection to a microphone or an external audio signal. 22
Starter Kit Audio Signal Paths dspic33f DSC OUTPUT COMPARE DCI & I 2 C 12-bit ADC SPI The starter kit board features two methods for capture and reproduction of audio signals. Both of these methods demonstrate the flexibility of a dspic DSC device. 23
Starter Kit Audio Signal Paths dspic33f DSC OUTPUT COMPARE DCI & I 2 C 12-bit ADC SPI The first method uses the dspic33f DSC 12-bit ADC and the Output Compare Pulse Width Modulated Playback technique to demonstrate a low cost yet effective technique for audio capture and playback. The 12- bit ADC of the dspic33f DSC provides an effective means for converting analog audio signals to digital signals in applications which are cost sensitive. The Output Compare PWM Playback technique only requires an external 4 th order low pass filter to reproduce the audio signal. The order of the filter directly affects the audio quality. Having a higher order filter improves the audio quality. 24
Starter Kit Audio Signal Paths dspic33f DSC OUTPUT COMPARE LOW PASS FILTER DCI & I 2 C 12-bit ADC SPI The Output Compare PWM Playback technique only requires an external 4 th order low pass filter to reproduce the audio signal. The order of the filter directly affects the audio quality. Having a higher order filter improves the audio quality. 25
Starter Kit Audio Signal Paths dspic33f DSC OUTPUT COMPARE LOW PASS FILTER DCI & I 2 C AUDIO CODEC 12-bit ADC SPI The second, or Audio Codec, method uses the external codec for the Analog to Digital and Digital to Analog conversion process. The Audio codec communicates with the dspic33f device via its versatile Data Converter Interface or the DCI modules and the I2C module. The dspic33f device uses the DCI module to communicate audio data with codec and the I2C module to provide control information. The codec is capable of performing a 16, 24 or 32 bit conversion at a maximum sampling rate of 48KHz. This makes the Audio codec ideal for applications that require high quality audio processing. 26
Starter Kit Audio Signal Paths dspic33f DSC OUTPUT COMPARE LOW PASS FILTER DCI & I 2 C AUDIO CODEC 12-bit ADC ANTI-ALIASING FILTER PRE-AMPLIER LINE MIC J7 SPI In either case, the board accepts audio input from a microphone or an output of audio equipment such as a CD player. Use jumper J7 to select between the two types of input. The input signal is then amplified. An antialiasing filter provides a cut-off at 3300Hz for the signal to be fed to the 12-bit ADC. 27
Starter Kit Audio Signal Paths dspic33f DSC OUTPUT COMPARE LOW PASS FILTER J6 HEADPHONE AMPLIFIER HEADPHONES DCI & I 2 C AUDIO CODEC 12-bit ADC ANTI-ALIASING FILTER PRE-AMPLIER LINE MIC J7 SPI The audio output can be selected between the output of the audio codec or the output of the Low Pass filter. The low pass filter demodulates the Pulse width modulated signal generated by the Output compare module. Use jumper J6 to select between the two. The headphone amplifier amplifies this signal for output to a headphone. 28
Starter Kit Audio Signal Paths dspic33f DSC OUTPUT COMPARE LOW PASS FILTER J6 HEADPHONE AMPLIFIER HEADPHONES DCI & I 2 C AUDIO CODEC 12-bit ADC ANTI-ALIASING FILTER PRE-AMPLIER LINE MIC J7 SPI SERIAL FLASH MEMORY An external 4 Mega Bit serial flash memory is available for storing data. This memory can be used in Speech Record and Playback type of applications. The serial flash memory interfaces to the SPI module on the dspic33f device. 29
Starter Kit Jumpers, Connectors and Controls Let s take a look at the jumpers, connectors and controls on the Starter Kit Board. 30
Starter Kit Jumpers, Connectors and Controls The board has three connectors. Use connector J1 to connect the board to the PC via the USB cable provided in the kit. 31
Starter Kit Jumpers, Connectors and Controls Use connector J9, labeled LINE IN/MIC, to connect either a microphone or audio equipment such as a CD player. 32
Starter Kit Jumpers, Connectors and Controls Use connector J8, labeled SPEAKER OUT, to connect to headphones. 33
Starter Kit Jumpers, Connectors and Controls Potentiometer R56, labeled MIC GAIN, adjusts the microphone pre-amplifier gain. This potentiometer must be set at the factory default level or turned completely clockwise for a nominal gain setting. The gain can then be increased by turning the potentiometer anti-clockwise. Note that increasing the gain too much can cause the input signal to distort and create an audio feedback. 34
Starter Kit Jumpers, Connectors and Controls J6 OCPWM CODEC The headphone signal is selectable between the output of the Output Compare Low Pass filter or the output of the Audio codec. 35
Starter Kit Jumpers, Connectors and Controls J6 OCPWM CODEC Place jumper J6 at OCPWM position for selecting the output of the Output Compare Low Pass Filter. 36
Starter Kit Jumpers, Connectors and Controls J6 OCPWM CODEC Place the Jumper in the CODEC position to use the Audio Codec. 37
Starter Kit Jumpers, Connectors and Controls MIC LINE J7 The input signal is selectable between a line level signal and a microphone. With the microphone option, the board provides the biasing voltage requires by condenser microphones. 38
Starter Kit Jumpers, Connectors and Controls MIC LINE J7 Set jumper J7 in MIC position to select a microphone. 39
Starter Kit Jumpers, Connectors and Controls MIC LINE J7 Place the jumper in LINE IN position to select a line level input. 40
The Speech Record and Playback Demo What you will need MPLAB Starter Kit for dspic DSCs Not included, but needed for demo: Headphones with 3.5mm stereo connector Microphone with 3.5mm connector Before we start with the Speech Record and Playback Demo, here s a list of the things that are needed for this demo. You first need the MPLAB Starter kit for dspic DSCs. Note that you don t need to program the starter kit board for the demo since the board is pre-programmed. You will need a set of headphones and a microphone. The ones that are usually used with PC s will work well with the board. Note that these are not provided with the kit. You are now ready to setup the demo. 41
The Speech Record and Playback Demo The starter kit board is factory programmed with a Speech Record and Playback Demo application. This application stores speech signals and plays them back when requested. To set up the board to use the demo: 42
The Speech Record and Playback Demo MICROPHONE Connect a microphone to the LINE IN / MIC socket J9. 43
The Speech Record and Playback Demo HEADPHONE MICROPHONE Connect a headphone to SPEAKER socket J8. 44
The Speech Record and Playback Demo HEADPHONE MICROPHONE Ensure the MIC GAIN potentiometer R56 is set at the factory default level. The arrow on the potentiometer wiper should align with the arrow mark on the board. 45
The Speech Record and Playback Demo HEADPHONE MICROPHONE J6 OCPWM CODEC Set Jumper J6 to CODEC position 46
The Speech Record and Playback Demo HEADPHONE MICROPHONE OCPWM J6 MIC LINE J7 CODEC Set jumper J7 to MIC position. 47
The Speech Record and Playback Demo HEADPHONE TO PC MICROPHONE OCPWM J6 MIC LINE J7 CODEC Connect the board to the PC using the USB cable. (You won t need MPLAB IDE to run the demo.) An introductory message will now playback on the headphones. This message introduces the Speech Record and Playback demo. This introductory message is stored on the serial flash memory device in an encoded form using the G.711 compression technique. The demo application can switch between two modes. In the record mode, the speech received through the microphone is processed and stored on the board serial flash memory. In the playback mode, speech data stored on the board serial flash memory is processed and reproduced on the headphones. 48
The Speech Record and Playback Demo - Recording From the previous setup, an introductory message should be playing back on the headphones. This message will be similar to the instructions you are about to be given now concerning recording and playback of your own audio. But first, here is a description of how recording works. 49
The Speech Record and Playback Demo - Recording PRESS S1 When you press switch S1, 50
The Speech Record and Playback Demo - Recording ERASING the Red LED will turn ON. This indicates that the application is preparing the serial flash memory for recording speech data by erasing the user section of the flash memory. 51
The Speech Record and Playback Demo - Recording RECORDING Once the erase operation is complete, the Red LED will turn off and the Yellow LED will turn on indicating that the application is in the record mode and is now recording. As you speak into the microphone, the application will acquire the digitized speech signal from the codec, compress this data using the G.711 compression technique and store the compressed data in the serial flash memory. The serial flash memory is capable of storing approximately 1 minute of speech while using the G.711 compression technique. When the serial flash memory has reached capacity, the application will automatically stop recording and switch to playback mode. Pressing switch S1 again will cause the erase and record process to start all over again. 52
The Speech Record and Playback Demo - Recording PRESS S1 So, to record your own audio: - Press switch S1. 53
The Speech Record and Playback Demo - Recording ERASING Wait for the Red LED to turn off 54
The Speech Record and Playback Demo - Recording RECORDING and the Yellow LED to turn on before recording. Record a message of approximately 1 minute or less. Proceed to the next step to play back your audio. 55
The Speech Record and Playback Demo - Playback To play back the audio you recorded in the previous step, 56
The Speech Record and Playback Demo - Playback PRESS S2 press switch S2. 57
The Speech Record and Playback Demo - Playback PLAYBACK The green LED will turn ON and the application is now in playback mode. Speech data stored in the serial flash is decompressed,converted to an analog signal by the codec and played out into the headphone via the headphone amplifier. 58
The Speech Record and Playback Demo - Playback PRESS S1 The playback operation will keep repeating till a new recording is started by pressing switch S1. The green LED will turn off. The stored speech data is erased when a new recording is performed. 59
References MPLAB Starter Kit For dspic Speech and Audio User Guide dspic33f Family Reference Manual (DS70046) dspic DSC Speech Coding Solution User s Guide (DS70295) This brings us to the end of the starter kit tutorial. 60