any insights / advice on the following would be much be appreciated:
i have several custom audio boards, some of which comply fairly close to the official adapter, as far as pin usage is concerned, some less so. now i've run into an issue which i don't know it can be solved in software or not. specifically, this concerns use of SPIFIFO and Frank B's play_serialflash library in conjunction with the SD card (using play_sd_wav, accessing the SD card, etc).
the issue, in brief is, is: these things work happily together when using SPIFIFO and a native CS pin; they won't work together, it seems, when any other pin is used as CS, ie other than the hardware CS pins. SPIFIFO resp. play_serialflash is fine when used on its own, ie even when not using a native CS pin.
long story short: i know too little about the ins and outs of the various SPI functionalities to figure out what's going on. i can see of course the hardware CS pins are treated differently in SPIFIFO.h, but i don't understand why using them is ok, while using other pins isn't.*
thanks...
* edit: what i can only suspect is that it must have to do with the SPI_PUSHR_EOQ or SPI_SR_EOQF registers, which get involved when using regular pins but not with the hardware CS pins.
** edit 2: i've tried wrapping the SPIFIFO write/read sections with beginTransaction() / endTransaction(), but that doesn't seem to make a difference and i'm not even sure these functions are meant to be used with SPIFIFO or how this might relate to using or not using the hardware CS.
============================
i don't think there'd be a simple way to reproduce the 'error', if it is, because i'd imagine most people if they use the w25Q128FV do so as part of the audio board. anyways, the phenomenon could be easily reproduced with any simple sketch, like the one below which works on the audio adapter (CS_MEM = 6), but refuses to work when moving CS_MEM to another (non-CS) pin. (the CS pin is declared in play_serialflash.h).
i have several custom audio boards, some of which comply fairly close to the official adapter, as far as pin usage is concerned, some less so. now i've run into an issue which i don't know it can be solved in software or not. specifically, this concerns use of SPIFIFO and Frank B's play_serialflash library in conjunction with the SD card (using play_sd_wav, accessing the SD card, etc).
the issue, in brief is, is: these things work happily together when using SPIFIFO and a native CS pin; they won't work together, it seems, when any other pin is used as CS, ie other than the hardware CS pins. SPIFIFO resp. play_serialflash is fine when used on its own, ie even when not using a native CS pin.
long story short: i know too little about the ins and outs of the various SPI functionalities to figure out what's going on. i can see of course the hardware CS pins are treated differently in SPIFIFO.h, but i don't understand why using them is ok, while using other pins isn't.*
thanks...
* edit: what i can only suspect is that it must have to do with the SPI_PUSHR_EOQ or SPI_SR_EOQF registers, which get involved when using regular pins but not with the hardware CS pins.
** edit 2: i've tried wrapping the SPIFIFO write/read sections with beginTransaction() / endTransaction(), but that doesn't seem to make a difference and i'm not even sure these functions are meant to be used with SPIFIFO or how this might relate to using or not using the hardware CS.
============================
i don't think there'd be a simple way to reproduce the 'error', if it is, because i'd imagine most people if they use the w25Q128FV do so as part of the audio board. anyways, the phenomenon could be easily reproduced with any simple sketch, like the one below which works on the audio adapter (CS_MEM = 6), but refuses to work when moving CS_MEM to another (non-CS) pin. (the CS pin is declared in play_serialflash.h).
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <play_serialflash.h>
AudioPlaySerialFlash raw1;
AudioPlaySdWav wav1;
AudioMixer4 mix;
AudioOutputI2S dac;
// NB: not using SGTL5000, so no i2c stuff here
AudioConnection cx(raw1, 0, mix, 0);
AudioConnection cy(wav1, 0, mix, 1);
AudioConnection c0(mix, 0, dac, 0);
AudioConnection c1(mix, 0, dac, 1);
#define CS_SD 10
void setup() {
pinMode(CS_SD, OUTPUT);
digitalWrite(CS_SD, HIGH);
AudioMemory(10);
SPI.setMOSI(7);
SPI.setSCK(14);
if (SD.begin(CS_SD)) {
Serial.println("ok");
}
}
uint32_t wait;
void loop() {
if (millis() - wait > 1000) {
/* play both from flash and SD: both work fine on their own, but not together with non-native CS */
raw1.play(0xAA00);
wav1.play("atari.wav");
wait = millis();
}
}
Last edited: