Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*****************************************************************************/
- /* */
- /* PROJECT */
- /* Sinewaves */
- /* */
- /* FILENAME */
- /* main.c */
- /* */
- /* DESCRIPTION */
- /* TMS320C5505 USB Stick Application 4. Generating sine waves. */
- /* Generating sinewaves of variable frequency using DSPLIB. */
- /* */
- /* REVISION */
- /* Revision: 1.00 */
- /* Author : Richard Sikora */
- /*---------------------------------------------------------------------------*/
- /* */
- /* HISTORY */
- /* */
- /* Revision 1.00 */
- /* 1st March 2010. Original template code Spectrum Digital. */
- /* */
- /* Revision 1.01 */
- /* 5th August 2010. Converted to use CSL. */
- /* */
- /*****************************************************************************/
- /*
- * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
- *
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of Texas Instruments Incorporated nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
- #include "stdio.h"
- #include "usbstk5505.h"
- #include "aic3204.h"
- #include "PLL.h"
- #include "sinewaves.h"
- Int16 left_input;
- Int16 right_input;
- Int16 left_output;
- Int16 right_output;
- Int16 left[512];
- Int16 right[512];
- Int16 idx = 0;
- #define SAMPLES_PER_SECOND 24000
- #define GAIN_IN_dB 0
- unsigned long int i = 0;
- /* ------------------------------------------------------------------------ *
- * *
- * main( ) *
- * *
- * ------------------------------------------------------------------------ */
- void main( void )
- {
- /* Initialize BSL */
- USBSTK5505_init( );
- /* Initialize the Phase Locked Loop in EEPROM */
- pll_frequency_setup(100);
- /* Initialise hardware interface and I2C for code */
- aic3204_hardware_init();
- /* Initialise the AIC3204 codec */
- aic3204_init();
- /* Set sampling frequency in Hz and ADC gain in dB */
- set_sampling_frequency_and_gain(SAMPLES_PER_SECOND, GAIN_IN_dB);
- printf("\nRunning Sinewaves Project\n\n");
- printf( "Sinewave 250Hz on left HP output, 1000Hz on right HP output\n\n" );
- asm(" bclr XF");
- for ( i = 0 ; i < SAMPLES_PER_SECOND * 600L ;i++ )
- {
- aic3204_codec_read(&left_input, &right_input); // Configured for one interrupt per two channels.
- left_output = 4 * generate_sinewave_1(500, 10000); // Sinewave 1 is 250 Hz.
- right_output = generate_sinewave_2(523, 10000); // Sinewave 2 is 1000 Hz.
- aic3204_codec_write(left_output, right_output);
- left[idx] = left_output;
- right[idx] = right_output;
- idx+=1;
- if(idx == 512)
- idx = 0;
- }
- /* Disable I2S and put codec into reset */
- aic3204_disable();
- printf( "\n***Program has Terminated***\n" );
- SW_BREAKPOINT;
- }
- /* ------------------------------------------------------------------------ *
- * *
- * End of main.c *
- * *
- * ------------------------------------------------------------------------ */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement