okenido
Posts: 57
Joined: Thu Aug 02, 2018 11:47 am

Atmega328p + RPI : ICSP programming providing 3.3V

Sun May 19, 2019 1:25 pm

Hi,
I made a circuit which uses a raspberry pi and an atmega328p microcontroller, which gets its power from rpi's 3.3V pin. I added an ICSP header so we can program the microcontroller directly on board after everything was assembled.

Normally, I would program it before connecting the raspberry pi, but if for some reason it is connected, can this be harmful for the raspberry pi ? (we're talking about providing 3.3V though the header pin while everything else is NOT powered -- the raspberry doesn't get its main 5V input)

User avatar
AdamStanislav
Posts: 124
Joined: Sun Mar 10, 2019 2:44 am
Location: Wisconsin
Contact: YouTube

Re: Atmega328p + RPI : ICSP programming providing 3.3V

Sun May 19, 2019 3:20 pm

okenido wrote:
Sun May 19, 2019 1:25 pm
we're talking about providing 3.3V though the header pin while everything else is NOT powered -- the raspberry doesn't get its main 5V input
You have lost me there. If the RPi does not get its main 5V input, where does the 3.3V output come from?

User avatar
davidcoton
Posts: 3940
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK

Re: Atmega328p + RPI : ICSP programming providing 3.3V

Sun May 19, 2019 3:26 pm

I would not recommend applying external 3V3 to the Pi GPIO header pin 3V3 under any circumstances, whether ther Pi is powered or not. The pin is designed for providing a 3V3 source; using it as a sink could damage the Pi, probably permanently and completely. The Pi 3B+ (and 3A+?) is particularly sensitive to this, but other models may also suffer.
Signature retired

okenido
Posts: 57
Joined: Thu Aug 02, 2018 11:47 am

Re: Atmega328p + RPI : ICSP programming providing 3.3V

Sun May 19, 2019 4:55 pm

AdamStanislav wrote:
Sun May 19, 2019 3:20 pm
okenido wrote:
Sun May 19, 2019 1:25 pm
we're talking about providing 3.3V though the header pin while everything else is NOT powered -- the raspberry doesn't get its main 5V input
You have lost me there. If the RPi does not get its main 5V input, where does the 3.3V output come from?
sorry, i talk about providing 3.3V unintentionally while programming the Atmega328p through the ICSP header. It's needed to program it, but as a side effect the 3.3V is also going to the raspberry.

How would you protect from that to happen ? A jumper somewhere to cut the 3.3V line between the atmega and the rpi ?

User avatar
AdamStanislav
Posts: 124
Joined: Sun Mar 10, 2019 2:44 am
Location: Wisconsin
Contact: YouTube

Re: Atmega328p + RPI : ICSP programming providing 3.3V

Sun May 19, 2019 6:08 pm

Would a diode work?

Brandon92
Posts: 773
Joined: Wed Jul 25, 2018 9:29 pm
Location: Netherlands

Re: Atmega328p + RPI : ICSP programming providing 3.3V

Sun May 19, 2019 7:06 pm

Here are some options I think:
  • You could program the uc before you solder it onto the board
  • Use a mosfet as a ideal diode.
  • Use a jumper, like you suggested
  • Power the Rpi without the sd card? And use the given 3,3v for programming.

dave j
Posts: 116
Joined: Mon Mar 05, 2012 2:19 pm

Re: Atmega328p + RPI : ICSP programming providing 3.3V

Sun May 19, 2019 7:09 pm

Have your thought of programming the AVR using the Pi?

Using this page: Using Raspberry Pi as an Arduino (AVR) programmer and information in the Arduino IDE's files I've been able to program Arduino clones that use ATmega32U4. (That page is a bit out of date - the current Raspbian avrdude is built with linuxgpio support.)

To completely reprogram the MCU from scratch I use:

Code: Select all

avrdude -p m32u4 -c linuxgpio -F -v -e -U efuse:w:0xcb:m -U hfuse:w:0xd8:m -U lfuse:w:0xff:m

avrdude -p m32u4 -c linuxgpio -F -v -e -U flash:w:Caterina-Leonardo.hex -U lock:w:0x2f:m
The values for efuse, hfuse, lfuse and lock are from the Arduino boards.txt file - you'll need the check the values for your MCU. The Caterina-Leonardo.hex is the Arduino boot loader for the Arduino Leonardo.

Return to “General discussion”