Go Down

Topic: SPI Slave Reverse Engineering! (Read 269 times) previous topic - next topic

blaupunkt

Hello dear Forum
First, I apologize for my English,
I'm still learning it;)
I have a cool project. I hope you can help?

I have a Renesas M16C microcontroller that sends me data via SPI BUS. max. Speed ​​720 kHz.
I would like to connect an Arduino Uno as a slave, receive the data and send to the serial port (USB).
It's a reverse Engineering Project. The Arduino replace a COG LCD Display.
M16C --> (Display „old") --> (Arduino „new") --> USB (COM Port) --> Processing 3 --> Draw Display on PC.

I have been searching for so many hours on the internet, even nick gammon website etc. Normal SPI-connection (2 Arduino's) with Master and Slave works great.

My question:
How should I program the Slave? The Arduino should max. receive 132 bytes as a slave, save them in a buffer and then output them with Serial.print (). He does not have to answer the master, only receive.
Do you have any ideas how I can do it? (Buffer Array etc?),
or maybe Code-Example? So that I can learn how such a thing is structured.

thank you and best regards...

blaupunkt

I know how the M16C fill the old Display.

I would only know how i should Set-UP the Arduino as an slave. (132 Bytes Buffer, Array, Interrupt  etc..)

Thank you

blaupunkt


pylon

If you take Nick Gammon's slave code you have a good base to work on. It even already add to an array to buffer incoming data. Try to extend that and post your code if you get stuck.

blaupunkt

thank you
ok i will try it. can i change the interrupt (\n)? because i have no new line. for example (after 132 bytes are recieved, then process it)

pylon

Sure you can modify that. Just never call any method of the Serial object inside the ISR. Use flag variables to communicate with the main loop routine and don't forget to declare them volatile as they are accessed inside interrupt context, otherwise the compiler may optimize it away.

blaupunkt

thank you very much

have someone an example for me? that i know wherei can start? :)

Go Up