# Can I program 5V ATmega328P using 3.3V ICSP bus?

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

• 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. – T J Nov 11 '14 at 8:44
• How will the AVR be powered while it is being programmed? – Ignacio Vazquez-Abrams Nov 11 '14 at 23:56
• @IgnacioVazquez-Abrams The AVR is powered from the Pi's 5V rail. – Maxthon Chan Nov 12 '14 at 12:14

• The unidirectional level translating can be done using some 74LVC1G07's or 74LVC1T245's. – Maxthon Chan Nov 12 '14 at 15:05