Hi, i might have made it hard on myself on this project.
Perhaps it's best to start at the beginning. My final thesis is about extracting high resolution data. This data (in this case) will be generated at 90 kHz, i know it's not very fast for Arduino's. The transportation "line" (fieldbus) has a maximum speed of around 30 kHz. This means i need to buffer my generated data, since i don't want to lose any of it. So far it's pretty straight forward.
Now i've decided to use SPI communication. The way i've setup my case is as follows:
Slave1 > Master > Slave2
Slave1 = Simulation of my data generation. (Arduino Uno)
Master = Arduino DUE, this because it has the possibility to switch between multiple slaves
Slave2 = The fieldbus slave, which gives an interrupt to the master which than has to send data to the slave (Arduino Uno).
So since i'm pretty new to SPI i thought let's start with basics. I used the example code from Gammon Forum : Electronics : Microprocessors : SPI - Serial Peripheral Interface - for Arduino which has been very helpful.
I've been able to send data from the master to the slaves, simple texts. Without the interrupt it always "talks" with Slave 1 and with an interrupt it "talks" with Slave 2. So far so good.
Now which apparently is quite hard to do, i want Slave 1 to send data to the Master, instead of the Master sending data to the Slave. Like i mentioned before, i'd like to be able to send out data which will be generating within that Arduino to the master. This data are kind of counters which can go up to a value of 17-bits.
All the codes i've been able to find are ones where the Master sends data only. While SPI is a full duplex communication. I've also found in the link i mentioned earlier an example of a code where the slave actually sends some kind of information back to the master. It takes out a byte send by the master from the register of the SPI library (if i'm correct). It does it's a simple adding/substracting, puts the new value back in the register (SPDR), after the master has given a microsecond delay it takes that new value out of the register. With an arduino Uno as a master that works. The Arduino DUE is not accepting that it'll just return '0'.
For some reason the DUE can't be setup as a slave like the UNO. Which would make it 10 times easier since i would then quickly switch Slave 1 to a Master and the Master to a Slave (since it's possible for me to use two DUE's).
I've also read that it's supposed to be possible by sending the exact same amount of bytes from the master to the slave as the slave has to send to the master. No idea how to realise that (keep the type of arduino's in mind).
I'd be able to remove the simulation Arduino and simulate the data generation within the master, however this means i'd leave out quite a big part of my "Proof of concept" situation.
So my question in simple form is like: How can i send a buffer of data from my slave to my master.
I hope somebody is able to help me with my problem, if i was still too cryptic about something my sincere apologies.
I did quite some extensive research on this, normally i always find a solution within the forum unfortunately not this time.
Kind regards and thanks in advance!