Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

WM8731MikroSine.ino 2.4KB

pirms 10 gadiem
pirms 10 gadiem
pirms 10 gadiem
pirms 10 gadiem
pirms 10 gadiem
pirms 10 gadiem
pirms 10 gadiem
pirms 10 gadiem
pirms 10 gadiem
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // Simple sine wave & input level test for WM8731 Audio Codec Board
  2. //
  3. // Requires the MikroElektronika Audio Codec board or similar hardware
  4. // http://www.mikroe.com/add-on-boards/audio-voice/audio-codec-proto/
  5. //
  6. // When using AudioInputI2Sslave & AudioOutputI2Sslave with MikroE-506,
  7. // the sample rate will be the crystal frequency divided by 256. The
  8. // MikroE-506 comes with a 12.288 MHz crystal, for 48 kHz sample rate.
  9. // To get 44.1 kHz (as expected by the Teensy Audio Library) the crystal
  10. // should be replaced with 11.2896 MHz.
  11. //
  12. // Recommended connections:
  13. //
  14. // Mikroe Teensy 3.1
  15. // ------ ----------
  16. // SCK 9
  17. // MISO 13
  18. // MOSI 22
  19. // ADCL 23 (yes, ADCL & DACL connect together)
  20. // DACL 23
  21. // SDA 18
  22. // SCL 19
  23. // 3.3V +3.3V
  24. // GND GND
  25. //
  26. // This example code is in the public domain.
  27. #include <Audio.h>
  28. #include <Wire.h>
  29. #include <SPI.h>
  30. #include <SD.h>
  31. #include <SerialFlash.h>
  32. // GUItool: begin automatically generated code
  33. AudioSynthWaveform waveform1; //xy=245,160
  34. AudioInputI2Sslave i2sslave1; //xy=265,252
  35. AudioOutputI2Sslave i2sslave2; //xy=429,158
  36. AudioAnalyzeRMS rms2; //xy=436,323
  37. AudioAnalyzeRMS rms1; //xy=444,265
  38. AudioConnection patchCord1(waveform1, 0, i2sslave2, 0);
  39. AudioConnection patchCord2(waveform1, 0, i2sslave2, 1);
  40. AudioConnection patchCord3(i2sslave1, 0, rms1, 0);
  41. AudioConnection patchCord4(i2sslave1, 1, rms2, 0);
  42. AudioControlWM8731master wm8731m1; //xy=292,379
  43. // GUItool: end automatically generated code
  44. void setup() {
  45. wm8731m1.enable();
  46. AudioMemory(15);
  47. waveform1.begin(WAVEFORM_SINE);
  48. waveform1.frequency(440);
  49. waveform1.amplitude(0.9);
  50. wm8731m1.volume(0.50);
  51. wm8731m1.inputSelect(AUDIO_INPUT_MIC);
  52. // wm8731m1.inputSelect(AUDIO_INPUT_LINEIN); // not connected on MikroE-506
  53. }
  54. elapsedMillis msec;
  55. // Print a simple level meter
  56. void loop() {
  57. if (msec > 40) {
  58. if (rms1.available() && rms2.available()) {
  59. msec = 0;
  60. int level_left = rms1.read() * 30.0;
  61. int level_right = rms2.read() * 30.0;
  62. printchar(' ', 30 - level_left);
  63. printchar('<', level_left);
  64. Serial.print("||");
  65. printchar('>', level_right);
  66. Serial.println();
  67. }
  68. }
  69. }
  70. void printchar(char c, int num) {
  71. for (int i=0; i < num; i++) {
  72. Serial.write(c);
  73. }
  74. }