Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. #include "stdio.h"
  2. #include "usbstk5505.h"
  3. #include "aic3204.h"
  4. #include "PLL.h"
  5. #include "sinewaves.h"
  6.  
  7.  
  8. Int16 left_input;
  9. Int16 right_input;
  10. Int16 left_output;
  11. Int16 right_output;
  12.  
  13.  
  14. #define SAMPLES_PER_SECOND 24000
  15. #define GAIN_IN_dB 0
  16.  
  17. unsigned long int i = 0;
  18.  
  19.  
  20. /* ------------------------------------------------------------------------ *
  21. * *
  22. * main( ) *
  23. * *
  24. * ------------------------------------------------------------------------ */
  25. void main( void )
  26. {
  27. /* Initialize BSL */
  28. USBSTK5505_init( );
  29.  
  30. /* Initialize the Phase Locked Loop in EEPROM */
  31. pll_frequency_setup(100);
  32.  
  33. /* Initialise hardware interface and I2C for code */
  34. aic3204_hardware_init();
  35.  
  36. /* Initialise the AIC3204 codec */
  37. aic3204_init();
  38.  
  39. Int16 left[512];
  40. Int16 right [512];
  41. Int16 idx=0;
  42.  
  43. /* Set sampling frequency in Hz and ADC gain in dB */
  44. set_sampling_frequency_and_gain(SAMPLES_PER_SECOND, GAIN_IN_dB);
  45.  
  46. printf("\nRunning Sinewaves Project\n\n");
  47. printf( "Sinewave 250Hz on left HP output, 1000Hz on right HP output\n\n" );
  48.  
  49. asm(" bclr XF");
  50.  
  51. for ( i = 0 ; i < SAMPLES_PER_SECOND * 600L ;i++ )
  52. {
  53.  
  54. aic3204_codec_read(&left_input, &right_input); // Configured for one interrupt per two channels.
  55.  
  56. left_output = generate_sinewave_1(2000, 5000); // Sinewave 1 is 250 Hz.
  57. right_output = generate_sinewave_2(2000, 5000); // Sinewave 2 is 1000 Hz.
  58.  
  59. aic3204_codec_write(left_output, right_output);
  60.  
  61. left [idx] = left_output;
  62. right [idx] = right_output;
  63. idx=idx+1;
  64. if(idx==512)
  65. idx=0;
  66. }
  67.  
  68. /* Disable I2S and put codec into reset */
  69. aic3204_disable();
  70.  
  71. printf( "\n***Program has Terminated***\n" );
  72. SW_BREAKPOINT;
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement