Atmega328p voltage connections confusion

arduinoatmegabluetoothicsp

I am designing a board relying on atmega328p.
In order to be able to load the arduino bootloader I added ICSP pins and connected them accordingly. Pin number 2 is VCC pin and I connected it to VCC pin of the atmega. I also have a step-up voltage converter which gets 1.5 volts and increase it to 3.3 steady voltage and this output is also connected to VCC pin of the atmega. Furthermore, there is a mini USB connection and it also contains a Vbus pin which, I reckon, should be connected to atmega's VCC line so that when the USB is connected, it can power the atmega for serial communication (There is also a CH340G serial converter connected to USB port).

Okay so, when the USB connection is present, battery should not be connected I believe. Because there is 3.3V coming from the battery and another 5V coming from the USB and they all are connected to atmega. How can I tackle this problem, or even is this a problem ?

Another concern is the bluetooth module also connected to VCC line from the battery. This BLE module (HM-11) cannot take 5Volts. So, another problem occurs at this point. If I connect the USB, this 5V VCC line from the USB will also try to power the Bluetooth module and probably damage it.

I also have no idea what voltage comes when I connect ICSP pins to an arduino for bootloading. Even this might be a problem for the Bluetooth in the first place.

All in all I am a bit confused about these VCC lines.

Best Answer

First things first - DO NOT APPLY POWER TO ANYTHING UNTIL YOU HAVE THIS FIGURED OUT.

You absolutely cannot have a common node with multiple voltages - this goes against fundamental circuit theory. Current will flow in directions it shouldn't and fry multiple things at once in an attempt to equalize the voltages.


The Short Answer

Actually, nothing has to share the VCC line. Absolutely every part and component can be powered from individual sources at varying voltage levels; however, every single part of the circuit must share a common ground line - this is the reference point for all voltages.


Circuit Design

Your description was good enough for me to create this schematic. I believe I have included everything you mentioned, but let me know if I left something out.

enter image description here

Now let's step through things one at a time.

mega328p

The ATmega328p has a very wide voltage range - it is happy anywhere from 1.2 to 5V DC; however, you shouldn't randomly change the supply voltage level, as this could have unintended effects on your circuit. Since your bluetooth module requires 3.3V, that should be your voltage level for VCC.

In the schematic, I have included 0.1uF ceramic capacitors on every VCC pin. These decoupling caps are not required, but are standard practice.

ISP

This is the in-system programming interface for most all AVR chips, and is used to directly program the chip's memory. This is also how you can flash a bootloader, EEPROM data, and set the FUSE or LOCK bits. In order to use this interface, you will need an external programmer. A fantastic one is the inexpensive AVR pocket programmer from Sparkfun. However, by your description, it sounds as though you are planning to use an Arudino as the external programmer. This will work for this purpose, but is ill-advised as a general purpose programmer.

The voltage of the ISP line signals and the VCC pin of the ISP header will be identical to the source voltage of the programmer. In the case of USB programmers like the one I linked, it will be 5V. Many older programmers actually require the destination circuit to power the programmer. If you are using an Arduino board as the programmer, the ISP voltage will be whatever source voltage the Arduino uses (5V for older models, 3.3V for newer models).

However, unless the external programmer has to be powered by the target board, you don't have to connect anything to the ISP VCC pin as long as the chip is powered in someway. They do have to share a common ground line.

Boost Regulator

Based on your voltages, I presume this is being used to step up voltage from a single alkaline battery...? This will work fine; however, RF circuits (like bluetooth) can be very power hungry if they are used frequently. You might be changing the battery much more often than you'd like.

This can be the source voltage for all circuit components. Connect the 3.3V output to the VCC pins of the atmega328p and the HM-11.

BLE HM-11

This is simple, connect to the 3.3V regulator output. Also of note, this module works using the serial port, which is how you will program the atmega328p if using the Arduino IDE and bootloader... Later Arduino boards had circuit design to allow use of the serial port for programming AND external parts, but you will probably need to use a jumper to select what is connected.

CH340g and USB

First, I have to say, this is a cheap, junky chip. Much better options exist. This chip can use either 5V or 3.3V as the source (VCC pin), depending upon how you connect the V3 pin. This chip also requires an external 0.1uF decoupling capacitor. According to the datasheet, it is not optional.

You can save power by only powering this chip from the USB connection (5V). Then, it will only be on when there is a USB connection. This 5V line from USB should not be connected to any other VCC lines in the circuit.


Conclusion

  • Circuit will be 100% battery powered...
  • Connect 3.3V boost regulator output to BLE HM-11 & atmega328p VCC pins
  • Don't connect anything to ISP VCC line
  • Connect CH340 VCC to the USB 5V line and nothing else
  • All parts must share a common ground line