Hi
I'm trying to make my Bass Audio Synth wireless.
The synth uses AudioPlaySerialflashRaw from a flash memory.
Each time a key is pressed it play a tone from the memory.
All this works perfectly.
I have added the radio receiver RFM69HCW from AdaFruit to the same SPI as the memory.
The driver is RadioHead RH_RF69
It works as expected as long as I don't use it to play a tone from the memory.
After a while the card hangs.
I have uncommented: #define SPI_TRANSACTION_MISMATCH_LED 23 in SPI.h
The LED lights up each time it hangs.
The problem is how to debug when it occurs.
But if I use the LowPowerLab driver RFM69 it never hangs.
Unfortunately this driver lacks speed. Radiohead seems to be faster.
Grateful for suggestions on how to solve the problem.
Code:
#include <Audio.h>
#include <Bounce2.h>
#include <MIDI.h>
//#include <RFM69.h> //LowPowerLab
#include <RH_RF69.h> //Radiohead
/************ Radio Setup ***************/
#define NETWORKID 100 //the same on all nodes that talk to each other
#define RECEIVER 1 //unique ID of the gateway/receiver
#define SENDER 2
#define NODEID RECEIVER //change to "SENDER" if this is the sender node (the one with the button)
#define RFM69_RST 6
#define RFM69_CS 9
#define RFM69_INT digitalPinToInterrupt(8)
//Match frequency to the hardware version of the radio on your Feather
#define FREQUENCY RF69_868MHZ
#define ENCRYPTKEY "sampleEncryptKey" //exactly the same 16 characters/bytes on all nodes!
#define IS_RFM69HCW true // set to 'true' if you are using an RFM69HCW module
//Initialize radio
//RFM69 radio = RFM69(RFM69_CS, RFM69_INT, IS_RFM69HCW, RFM69_INT);
RH_RF69 rf69(RFM69_CS,RFM69_INT);
MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI);
// Create the Audio components. These should be created in the
// order data flows, inputs/sources -> processing -> outputs
//
// basstämma
AudioPlaySerialflashRaw bas0;
AudioEffectEnvelope env0;
// ackordskomp 3-4 stämmor samtidigt
AudioPlaySerialflashRaw acc[4];
AudioMixer4 mix0;
AudioMixer4 mix1;
AudioOutputPT8211 ptout;
// basen
AudioConnection c0(bas0, 0, env0, 0);
// kompet in i mixer 0
AudioConnection c2(acc[0], 0, mix0, 0);
AudioConnection c3(acc[1], 0, mix0, 1);
AudioConnection c4(acc[2], 0, mix0, 2);
AudioConnection c5(acc[3], 0, mix0, 3);
// mixa ihop bas och komp
AudioConnection c11(env0, 0, mix1, 0);
AudioConnection c12(mix0, 0, mix1, 1);
// output t0 PT8211 dac (both L och R)
//AudioConnection c20(mix1, 0, ptout, 0);
AudioConnection c21(mix1, 0, ptout, 1);
void setup() {
Serial.begin(9600);
delay(500); // så att serial kommer igång
MIDI.begin(MIDI_CHANNEL_OMNI);
//For Teensy 3.x and T4.x the following format is required to operate correctly
pinMode(RFM69_RST, OUTPUT);
digitalWrite(RFM69_RST, LOW);
delay(100);
Serial.println("Midi interface med trådlös modul RFM69HCW!");
digitalWrite(RFM69_RST, HIGH);
delay(100);
digitalWrite(RFM69_RST, LOW);
delay(100);
/*
if (radio.initialize(FREQUENCY, NODEID, NETWORKID)) {
Serial.println("radio initialized ");
}
if (IS_RFM69HCW) {
radio.setHighPower(); // Only for RFM69HCW & HW!
}
radio.setPowerLevel(31); // power output ranges from 0 (5dBm) to 31 (20dBm)
radio.encrypt(ENCRYPTKEY);
Serial.print(FREQUENCY == RF69_433MHZ ? 433 : FREQUENCY == RF69_868MHZ ? 868 : 915);
Serial.println(" MHz");
*/
if (!rf69.init())
Serial.println("init failed");
// Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM
// No encryption
if (!rf69.setFrequency(868.0))
Serial.println("setFrequency failed");
// If you are using a high power RF69, you *must* set a Tx power in the
// range 14 to 20 like this:
rf69.setTxPower(14);
rf69.setModeRx();
//rf69.setEncryptionKey((uint8_t*)ENCRYPTKEY);
//Set up SPI flashminne
if (!SerialFlash.begin(CSPIN)) {
while (1) {
Serial.println("Unable to access SPI Flash chip");
delay(1000);
}
}
}
I'm trying to make my Bass Audio Synth wireless.
The synth uses AudioPlaySerialflashRaw from a flash memory.
Each time a key is pressed it play a tone from the memory.
All this works perfectly.
I have added the radio receiver RFM69HCW from AdaFruit to the same SPI as the memory.
The driver is RadioHead RH_RF69
It works as expected as long as I don't use it to play a tone from the memory.
After a while the card hangs.
I have uncommented: #define SPI_TRANSACTION_MISMATCH_LED 23 in SPI.h
The LED lights up each time it hangs.
The problem is how to debug when it occurs.
But if I use the LowPowerLab driver RFM69 it never hangs.
Unfortunately this driver lacks speed. Radiohead seems to be faster.
Grateful for suggestions on how to solve the problem.
Code:
#include <Audio.h>
#include <Bounce2.h>
#include <MIDI.h>
//#include <RFM69.h> //LowPowerLab
#include <RH_RF69.h> //Radiohead
/************ Radio Setup ***************/
#define NETWORKID 100 //the same on all nodes that talk to each other
#define RECEIVER 1 //unique ID of the gateway/receiver
#define SENDER 2
#define NODEID RECEIVER //change to "SENDER" if this is the sender node (the one with the button)
#define RFM69_RST 6
#define RFM69_CS 9
#define RFM69_INT digitalPinToInterrupt(8)
//Match frequency to the hardware version of the radio on your Feather
#define FREQUENCY RF69_868MHZ
#define ENCRYPTKEY "sampleEncryptKey" //exactly the same 16 characters/bytes on all nodes!
#define IS_RFM69HCW true // set to 'true' if you are using an RFM69HCW module
//Initialize radio
//RFM69 radio = RFM69(RFM69_CS, RFM69_INT, IS_RFM69HCW, RFM69_INT);
RH_RF69 rf69(RFM69_CS,RFM69_INT);
MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI);
// Create the Audio components. These should be created in the
// order data flows, inputs/sources -> processing -> outputs
//
// basstämma
AudioPlaySerialflashRaw bas0;
AudioEffectEnvelope env0;
// ackordskomp 3-4 stämmor samtidigt
AudioPlaySerialflashRaw acc[4];
AudioMixer4 mix0;
AudioMixer4 mix1;
AudioOutputPT8211 ptout;
// basen
AudioConnection c0(bas0, 0, env0, 0);
// kompet in i mixer 0
AudioConnection c2(acc[0], 0, mix0, 0);
AudioConnection c3(acc[1], 0, mix0, 1);
AudioConnection c4(acc[2], 0, mix0, 2);
AudioConnection c5(acc[3], 0, mix0, 3);
// mixa ihop bas och komp
AudioConnection c11(env0, 0, mix1, 0);
AudioConnection c12(mix0, 0, mix1, 1);
// output t0 PT8211 dac (both L och R)
//AudioConnection c20(mix1, 0, ptout, 0);
AudioConnection c21(mix1, 0, ptout, 1);
void setup() {
Serial.begin(9600);
delay(500); // så att serial kommer igång
MIDI.begin(MIDI_CHANNEL_OMNI);
//For Teensy 3.x and T4.x the following format is required to operate correctly
pinMode(RFM69_RST, OUTPUT);
digitalWrite(RFM69_RST, LOW);
delay(100);
Serial.println("Midi interface med trådlös modul RFM69HCW!");
digitalWrite(RFM69_RST, HIGH);
delay(100);
digitalWrite(RFM69_RST, LOW);
delay(100);
/*
if (radio.initialize(FREQUENCY, NODEID, NETWORKID)) {
Serial.println("radio initialized ");
}
if (IS_RFM69HCW) {
radio.setHighPower(); // Only for RFM69HCW & HW!
}
radio.setPowerLevel(31); // power output ranges from 0 (5dBm) to 31 (20dBm)
radio.encrypt(ENCRYPTKEY);
Serial.print(FREQUENCY == RF69_433MHZ ? 433 : FREQUENCY == RF69_868MHZ ? 868 : 915);
Serial.println(" MHz");
*/
if (!rf69.init())
Serial.println("init failed");
// Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM
// No encryption
if (!rf69.setFrequency(868.0))
Serial.println("setFrequency failed");
// If you are using a high power RF69, you *must* set a Tx power in the
// range 14 to 20 like this:
rf69.setTxPower(14);
rf69.setModeRx();
//rf69.setEncryptionKey((uint8_t*)ENCRYPTKEY);
//Set up SPI flashminne
if (!SerialFlash.begin(CSPIN)) {
while (1) {
Serial.println("Unable to access SPI Flash chip");
delay(1000);
}
}
}