1

I posted this on the main Arduino forum, but no one has responded in 24 hours.

I'm trying to use the WaveHC library from Adafruit with a custom PCB. I am having trouble getting the SPI com to work for some reason, I modified the ArduinoPins.h, SS_PIN, from pin 10 to 8.

Using the Arduino SD library, I can see all the files no problem.

In the WaveHC library, all of the examples freeze after card.init(), I traced it to the spiSend(uint8_t b) in SdReader.cpp. It seems to get stuck in while(!(SPSR & (1 << SPIF)). This looks like the SPDR register (the SPI data register) is never loaded properly.

Does anyone know what is going on?

Adafruit library : https://github.com/adafruit/WaveHC

Edit : This is the output from the SDReadTest example (Arduino SD Library)

Initializing SD card...Wiring is correct and a card is present.

Card type: SD2

Volume type is FAT32

Volume size (bytes): 1973350400
Volume size (Kbytes): 1927100
Volume size (Mbytes): 1881

Files found on the card (name, date and size in bytes): 
SYSTEM~1/     2016-11-07 14:11:06
  INDEXE~1      2016-11-07 14:11:06 76
0.WAV         2016-11-07 11:44:14 22124
1.WAV         2016-11-07 11:44:14 18604
2.WAV         2016-11-07 11:44:14 19244
3.WAV         2016-11-07 11:44:14 19884
4.WAV         2016-11-07 11:44:14 21164
5.WAV         2016-11-07 11:44:14 23084
6.WAV         2016-11-07 11:44:14 21484
7.WAV         2016-11-07 11:44:14 29484
8.WAV         2016-11-07 11:44:14 20844
9.WAV         2016-11-07 11:44:14 25004
P.WAV         2016-11-07 11:44:14 21804

Notes :

  • I am using an Atmega328P @ 8MHz with the pro mini bootloader (this may be the issue)
  • SPI_DEFAULT_HALF_SPEED is set to true
  • SPI_INIT_SLOW is set to 1
10
  • 1
    Please post both code and circuit schematic.
    – Dat Ha
    Commented Nov 8, 2016 at 21:24
  • I have tried all the examples in their repository github.com/adafruit/WaveHC. A schematic is unnecessary, I have verified my connections by testing my board with the arduino SD library. Commented Nov 8, 2016 at 22:53
  • 1
    Please edit your question to include a link to your Arduino forum post. Try setting the pinMode of SS pin of your microcontroller(10 on ATmega328P, 53 on ATmega2560) to OUTPUT in your setup() function. Even though you can use any pin to control the SS pin of the SD card, you need to sure the microcontroller's SS pin doesn't go low while using SPI, otherwise it goes into slave mode. Other useful information would be which microcontroller you're using and whether you've tried using the WaveHC library with SS on pin 10.
    – per1234
    Commented Nov 9, 2016 at 0:20
  • The arduino post is copy and paste...and still no one has responded. The pinMode for the SS pin is in the init method in SdReader.cpp, also I already tried adding in another pinMode in the setup. I'm using the Atmega328P 8Mhz. I can't try to use pin 10 because it is a smd custom PCB. Commented Nov 9, 2016 at 0:46
  • Have you tried the suggestions in the WaveHC readme? Commented Nov 9, 2016 at 4:55

1 Answer 1

0

So the problem was that I did not read this comment carefully

/** SPI slave select pin. Warning: SS may be redefined as another pin
but the hardware SS_PIN must be set to output mode before any calls to
WaveHC functions. The SS_PIN can then be used as a general output pin */

"SS_PIN must be set to output mode before any calls to WaveHC functions"

I read this and thought that meant whatever pin was being used as the SS pin needed to be an output, but it meant literally that pin 10 (the hardware SS pin) had to be set as an output regardless of whether it was being used or not.

So the solution is to add

pinMode(10, OUTPUT);

to anywhere in the code

Edit : also thanks @per1234 for pointing out the correct answer, I just didn't read your comment properly.

1
  • Glad to hear you found the solution! Please update your post on the Arduino forum with a link to this page so that people there will know you no longer need assistance. This will also help anyone with the same problem who finds your post there to be led to the answer.
    – per1234
    Commented Nov 10, 2016 at 5:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.