Following tutorial audio - collect2: error: ld returned 1 exit status Error compiling

Status
Not open for further replies.

dywen

Member
Error:
/tmp/buildbf0c872c012dd1eee7874d3cf8e26fef.tmp/core/core.a(main.cpp.o): In function `main':
/home/meme/Arduino_Teensy/arduino-1.6.9/hardware/teensy/avr/cores/teensy3/main.cpp:21: undefined reference to `setup'
/home/meme/Arduino_Teensy/arduino-1.6.9/hardware/teensy/avr/cores/teensy3/main.cpp:23: undefined reference to `loop'
collect2: error: ld returned 1 exit status
Error compiling for board Teensy 3.2 / 3.1.

Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>


// GUItool: begin automatically generated code
AudioPlaySdWav           playSdWav1;     //xy=218,161
AudioOutputI2S           i2s1;           //xy=421,179
AudioConnection          patchCord1(playSdWav1, 0, i2s1, 0);
AudioConnection          patchCord2(playSdWav1, 1, i2s1, 1);
AudioControlSGTL5000     sgtl5000_1;     //xy=252,286
// GUItool: end automatically generated code

Hi,
I'm going throught the online tutorial on audio and immediately I run into an error. This is the first sketch, automatically compiled via the audio Gui. It should play a file automatically. There are files on the sd card (of course :))
https://www.pjrc.com/teensy/td_libs_Audio.html

I run Linux Mint - other example sketches ran fluently (leds, buttons etc) I also managed to play sound via other pre-existint sketches.

Greetz
dywen
 
Others can probably answer better than me. I have gone through many of the examples of the tutorial... Keep meaning to finish...

But if I remember correctly, the instructions, will say something like: Open Example... of the audio tutorial and paste the output from the guitool into the correct location in the Arduino Sketch.

What you show above is just the Gui generated stuff and does not contain any of the main code, which includes the standard Arduino setup and loop functions.

Good Luck
 
Yep, I just realized that as well.
It was a matter of talking to the proverbial duck - thanks KurtE for your awesome duckiness :) and thanks forum..
https://en.wikipedia.org/wiki/Rubber_duck_debugging

The main code is quite cryptic, though..
Here is an explanation of what these do:

Code:
// function header 
void setup() {

  // Setup the serial monitor so that you can use [b]Serial.print[/b] or [b]Serial.println[/b] to write debug messages, on the Teensy the number is ignored
  Serial.begin(9600);

   // Allocate 8 buffers to use for the Audio library, if you are doing more complex processing, you probably want to increase this
  AudioMemory(8);

  // Enable the SGTL5000, this is the volume control
  sgtl5000_1.enable();

  // Set the volume to 1/2 (0.5) the default level
  sgtl5000_1.volume(0.5);

  // Set the SPI alternate pin for MOSI to 7.
  SPI.setMOSI(7);

  // Set the SPI alternate pin for SCLK to 14.
  SPI.setSCK(14);

  // Open the SD card using pin 10 as the chip select pin, return 0/false if there is an error
  if (!(SD.begin(10))) {

    // error handling code 
    [...]
  }
}

The SPI bus allows you to hang multiple devices off of it. The bus has 3 fixed pins, and one pin for each device:
  • MOSI (master output, slave input). Normally this is pin 11, but it can also be pin 7;
  • MISO (master input, slave output). Normally this is pin 12, but it can also be pin 8;
  • SCLK (spi clock). Normally this is pin 13, but it can also be pin 14.
  • CS (chip select, this is different for each device). You set this pin HIGH or LOW depending on the device to enable it, and when you reset the pin, the device will ignore all other commands on the SPI bus. The audio board uses pin 6 for the CS for the EEPROM memory that can be soldered to the board, and 10 for the micro SD card.
 
Status
Not open for further replies.
Back
Top