Problem in communication between ATmega2560(5v) board with SPI device(3.3V)

Hi Team ,
I am getting problem in making communication between Arduino ATmega2560 board (5v) with SPI device (3.3V). I made the necessary wired connection between these two boards and also i feel my code configuration for initializing SPI is also correct, but still i am not getting correct respose from SPI device. Is the voltage difference between two device can be reason for these issue, is it needed to connect voltage converter between them or u have any idea to connect these two baords in some other way.

yikes !!!

You can not connect normally connect the SPI connections to a 3.3V device

Normally you need to do level translation on the clock and also the data out (from the Arduino to the SPI device).

You can do this with a level shifting IC, often a resistor divider network of 1k and 2k will be enough.

Note. Some devices are 5V tollerant on their signal lines, but as you are having problems I suspect the device you are using is NOT one of these. In fact you may have already destroyed it

I am able to write to slave device but getting unwanted response from slave side, am i doing wrong or it can be a voltage issue... like if am writing 44 to spi it should have to return 5b but its returning FF. can it be reason of voltage difference or i am doing wrong in SPI configuration.

  1. Do you have voltage level translator? LIke 74HC4050 to go from 5V to 3.3V for SCK, MOSI, and CS? MISO from the device can stay at 3.3V level into the Mega2560.

  2. Post your code, otherwise we can only guess about what you doing in your SPI code.

  3. What is the device and how is it getting 3.3V for power?

Thanks for help,
I am able to get my SPI response, without attaching converters. Junk response was because of loose connections between host and target

Hi Crossroads,
Board was getting power from CPU USB.

I used a resistor and an LED as a voltage divider to do the level shifting for programming a 3v Atmega 328. It is only required in the 5v to 3v direction. The Arduino seems to be quite happy to receive 3v signals.

Another technique I came across recently is to tie the 3.3v line high through a resistor and use a diode to prevent 5v reaching the low end of the resistor. Then when the Arduino signal goes LOW it will pull the other signal LOW. I used that to connect a HC05 bluetooth device to an Arduino.

...R