C++ code for SPI communication b/w ATMega 644A & ATMega328

I want to communicate these two micro controllers (ATMega 644A & ATMega328) via SPI protocol.

My goal is to introduce a routine in the ATMega 644A (Master) so that it will know and can respond to the ATMega328 (Slave).

Will somebody help me with this !!!


The Pololu AVR library supports master SPI, which is half of what you need. The library contains the source code, so you can get an idea of how to do it yourself (you can download a zip file of the library here). Implementing the slave side should be pretty straightforward if you look at the ATmega328 datasheet. If there is something you don’t understand about the library code or the datasheet, please ask.

- Ben