4
\$\begingroup\$

schematic

simulate this circuit – Schematic created using CircuitLab

I'm trying to connect a ATmega328p and Raspberry Pi together, communicating via SPI. The Pi is Master and is used to program the ATmega when first connected, (ATmega is completely blank).

The ATmega will not respond to the programming mode command and I can't find why.

I have the Pi at 3.3V, and the ATmega at 5V (design does not allow for the ATmega to be run at 3.3v) with a 16Mhz crystal. They are connected via a txb0104 level shifter for the 4 SPI lines, and a pull-up resistor and transistor for the reset line.

Viewing the SPI inputs (+ reset) to the ATmega with an oscilloscope, I have Reset and SS going low, and SCK & MOSI clocking in the programming mode command (AC-53-00-00). I then receive no response from the MISO, and Pi is just attempts to send the programming mode command again after 10 seconds.

I have checked that the SPI lines are going to the correct pins, and any distortion from the level shifter seems negligible. I've also used an Arduino-as-isp to program a blank ATmega in the same setup, bypassing the level shifter so the Atmega should be setup correctly.

Is there anywhere I am likely going wrong here? Only thing I can think of is that my level shifter is unsuitable.

\$\endgroup\$
8
  • \$\begingroup\$ Instead of describing the schematic, draw one, edit and Ctrl+M to use the embedded schematic drawing tool. Also attach the scope image if possible. \$\endgroup\$ May 3, 2017 at 13:32
  • \$\begingroup\$ What are you clocking it at during programming? \$\endgroup\$
    – Matt Young
    May 3, 2017 at 14:04
  • \$\begingroup\$ The SPI clock is 500 KHz \$\endgroup\$
    – Snowsheer
    May 3, 2017 at 14:25
  • 2
    \$\begingroup\$ I'm voting to close this question as off-topic because it has been abandoned in unanswerable state for two years without followup \$\endgroup\$ Aug 1, 2019 at 19:05
  • 1
    \$\begingroup\$ I'm voting again to close this question as off-topic because it has been abandoned in unanswerable state for yet another year after the last time I voted to do this when it had already been abandoned for two years... \$\endgroup\$ Dec 8, 2020 at 17:24

3 Answers 3

1
\$\begingroup\$

The transistor circuit at the RST input acts as an inverter. Is that what you want? In other words, the reset-pi pin would need to be specified to invert the reset signal.

Btw. 3.3V is at the low end of acceptable gate voltage for a 2n7000. With an npn transistor you'd have a more robust voltage margin.

\$\endgroup\$
0
\$\begingroup\$

What side of the voltage translator were you probing the MISO signal for a response from the Arduino?

According to your schematic, you have the 5V side on port A and the 3.3V side on port B. According to the datasheet for the TXB0104, this should be the other way around (5V actually exceeds the max rating for VCCA).

http://www.ti.com/lit/ds/symlink/txb0104.pdf (See sections 6.1 and 8.1)

This may be causing the output from the Arduino to not make it through the level shifter.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ I've got the A/B labels mixed up on schematic. Measuring on oscilloscope is showing the signals from the Pi pass through it (and get shifted correctly) \$\endgroup\$
    – Snowsheer
    May 3, 2017 at 16:08
0
\$\begingroup\$

How are you supplying the 5V for the atmega, with the RPi? I had a similar problem for programming a cortex-m0 chip using a raspberry.

I solved my problem by connecting the ground of the raspberry with the ground of the chip.

Hope it will help

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.