1
\$\begingroup\$

I am considering building a microcontroller HAT for Raspberry Pi Model B+. Since the Pi have the SPI bus exposed and some avrdude fork supports using it directly, I am hoping that my HAT can allow Raspberry Pi talk to the ATmega328P using SPI ICSP for flashing the chip instead of using serial and some serial bootloader. However the pins should be disengaged from the Pi when not required so that other SPI peripherals can be connected to both devices too. Similar situation exists for I2C, UART buses and one GPIO pin. All pin dis/engaging is done using one PCF8574 chip on Pi's I2C bus.

I know very well that I can run the ATmega328P at 3.3V, possibly overclock it to 16MHz, but I am asking about doing this with the microcontroller running at 5V. At 3.3V disengaging the pins requires just some CD4066s

\$\endgroup\$
  • \$\begingroup\$ I think it is possible, normal Tx / Rx communication normally works also with a 3.3V device and a 5V microcontroller (ofc I had a voltage devider from 5V to 3.3V), so why can't the SPI part do it. 3.3V is probably high enough for the microcontroller to give a High state. \$\endgroup\$ – T J Nov 11 '14 at 8:44
  • \$\begingroup\$ How will the AVR be powered while it is being programmed? \$\endgroup\$ – Ignacio Vazquez-Abrams Nov 11 '14 at 23:56
  • \$\begingroup\$ @IgnacioVazquez-Abrams The AVR is powered from the Pi's 5V rail. \$\endgroup\$ – Maxthon Chan Nov 12 '14 at 12:14
1
\$\begingroup\$

This should work fine. As long as the 3.3v high level is high enough to register as a high level on the AVR, this should work correctly.

You should also add series resistors for current limiting so that the 5v level from the AVR pins do not damage the input on the SoC.

\$\endgroup\$
  • \$\begingroup\$ No. The MISO line will be driven too high by the 5v ATMEGA. \$\endgroup\$ – Chris Stratton Nov 11 '14 at 14:18
  • \$\begingroup\$ The unidirectional level translating can be done using some 74LVC1G07's or 74LVC1T245's. \$\endgroup\$ – Maxthon Chan Nov 12 '14 at 15:05
0
\$\begingroup\$

The pi will probably be fried because the MOSI pin will is driven by the Arduino. If you want to use the pi as your ICSP, you will need a level shifter such as this one.

\$\endgroup\$
  • \$\begingroup\$ Note I also need to disengage the pins when not used. Disengage, read tri-state. \$\endgroup\$ – Maxthon Chan Nov 12 '14 at 12:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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