3.3V Microprocessor with 5V ISP?

All of my circuitry runs at 3.3V, so I'm planning to run the microprocessor (328p) at 3.3V. Running everything at 3.3V is fine, when everything is programmed and operational, but what about before then? The parts are all surface mount components and it would be best if the circuit could be powered from the ISP header and not externally.

Can the ATmega328 be programmed when running at 3.3V (brownout detection)? What's the recommended way of interfacing the ISP lines (at 5.0V) with the 328 expecting 3.3V without disrupting (or damaging) the other sensors and components that need 3.3V?

Does anyone have any recommendations or procedures for accomplishing something like this?

There's no worries about the ATmega328 itself being programmed on 5V even if you're expecting to run it at 3.3V. But like you said, the concern is with whatever other components would be exposed to the 5V from the programmer. I use Adafruit's USBtinyISP which has a jumper to optionally prevent the programmer from putting power to the ICSP header (in which case the MCU will need to be powered via its intended 3.3V supply).

Something similar could be done on the target board itself, i.e. a jumper which when pulled disconnects everything but the MCU from the supply.

Jack, just for clarification, I plan on bit-banging the serial protocol (SPI) for all of my external devices, so the internal SPI hardware on the ATmega328p will be reserved only for in-system programming.

My current circuit layout looks something like this:

5.0V in --> 3.3V Regulator --> ATmega328p and Sensors

The only lines that will "cross" the 5.0V/3.3V barrier are the ISP/SPI SCLK, MISO, MOSI, and RESET lines. My plan up until this point was to tie the VCC lines of the ISP programmer to the 5.0V in line on my board. That way, the 5.0V would be stepped down to 3.3V before reaching the 328 or the sensors and other components. I'm just worried about interfacing the SCLK, MISO, MOSI, and RESET pins.

My other idea was to use a 4-bit bidirectional logic level converter (buffer) to convert the SPI lines, but I am still questioning the ability of the 328 to be programmed while operating at 3.3V. Does the flash EEPROM memory require 5.0V? I'm also not sure how to handle the interface or (for example) fuse programming. Do the chips come from the factory with the ability to be programmed at 3.3V? Hopefully that clarifies my intentions.

Do you have any new recommendations based on my interface design? Everything is theoretical at this point, so I can change anything.

Well I had started to write that all should be fine, then a light went on. The datasheet says that the voltage on any pin (except RESET -- for high-voltage programming) cannot be less than -0.5V or more than Vcc + 0.5V. So I wouldn't drive an MCU running on 3.3V with 5V signals. I'd either level-shift the programming signals or why not just run the programmer on 3.3V too. I've done ICSP programming at 3V and 3.3V as well as at 5V, flash as well as EEPROM should work down to 1.8V per the datasheet. I'd breadboard it up just to convince myself, but that's the way I'm reading it. I'd seriously lean toward running the programmer at 3.3V if possible, but if not, bi-directional level shifting seems like overkill. SCK and MOSI are inputs to the target, MISO is an output, etc., so one-way shifting should suffice.

HTH!

mechengr:
Does anyone have any recommendations or procedures for accomplishing something like this?

I'll simply add that you need to remember you're not programming the CPU to run at 3.3 volts, you're actually telling it to run at a lower speed (and a lower brown-out detection level) than 5V would allow.

Your ATmega is still a 5v tolerent design and will have no problems handling ICSP signals at that level.

Now if you hook up an ATmega running at 5v to a 3.3v SPI device, that's when problems occur (which is what Jack just said I think)

I hope this helps,

Brad.

EDIT: Minor typo

Second to the last paragraph...

There's a bunch of other ISP stuff in that topic that may be of interest.

Aha, I didn't realize that the programmers could run at 3.3V. I assumed (bad idea) that since the USB power was 5.0V, that the output voltages on the ISP lines were also 5.0V. It appears that the Atmel AVRISP MkII can drive the ISP lines at whatever voltage is required by the circuit (built in level shifters for ~1.8V to 5.0V), although it won't power the circuit from the USB (power applied externally?).

So, if my understanding is correct, I will have to power the circuit externally, connect the AVRISP to the circuit, change the settings in AVR Studio to 3.3V target voltage (in which case the AVRISP will measure the voltage on it's VCC/GND lines to ensure it's actually 3.3V), and then I can program without installing level shifters or anything else on my board. Sound right?

Just to clarify, does the ATmega ignore fuse-settings while RESET is held? The reason I ask is if the ATmega is setup for say 4.8V brown-out detection from the factory, and I solder it to my board, which will run at 3.3V, and then try to program it at 3.3V, will it still program? Once the fuses are properly set, I'd imagine this is not a problem, but what about before? Thanks!

Not being familiar with that particular programmer, I'm not sure if it is actually measuring the voltage, or just using the supply voltage presented to it through the programming header (I believe this is what the AFI programmer does). Also have not used AVR Studio (on my bucket list) so can't comment on what the 3.3V setting there actually does, hopefully someone else can comment.

I know that the ATmega does not ignore the fuse settings while being programmed, at least not the clock select settings. It's possible to get things into a state where it is difficult or maybe even impossible to program if unusual clock selections are made. Having said that, it doesn't seem to be a thing that happens all that often if the forum here is any indication.

Refer to the datasheet, however, and you will discover that the ATmega328 comes from the factory with the brownout detector disabled. (The Arduino Uno retains this BOD setting, BTW.) Atmel's default fuse settings are intended to ensure the chip is programmable in most common scenarios.