AVR ICSP - Circuit to prevent power on during programming - Page 1
Forum section: electronics / beginners

author: bitshift
author_rank: Regular Contributor
timestamp: February 04, 2016, 03:43:48 pm
content: Hey guys,I'm currently adding an ICSP header to a small board I am making. I would like to prevent the programmer from powering on the entire circuit when it is connected. One method to prevent this is to add a diode between your voltage regulator and the AVRs Vcc pin. When a programmer is connected, this diode is reverse biased so nothing else powers on. You would typically use a schottky for this.I've come up with an alternative where a P channel mosfet is switched on when no programmer is present and is switched off when a programmer is present. The small Rdson of the mosfet will make the voltage drop minimal. Here's a schematic:When the programmer is disconnected, +V is floating. The mosfet gate is pulled low, connecting the AVRs Vcc to +3.3V. D2 prevents the mosfet gate from going high. When the programmer is connected, +V is high which turns off the mosfet.Advantages of this over a simple Schottky diode:Vcc and Aref are at equal potentials (since there is no diode drop)Disadvantages of this over a simple Schottky diode:More componentsHigher costI came up with this mosfet scheme because I wanted to keep Vcc and Aref the same but I'm wondering now if this is a valid reason.Questions:Is it ok for Aref be slightly higher than Vcc?Is the simple Schottky diode the standard way of preventing full circuit power on?Are there any other common alternatives?

author: Ian.M
author_rank: Super Contributor
timestamp: February 04, 2016, 04:03:41 pm
content: You are going to run into problems with the MOSFET body diode and will need to swap D and S

author: rob77
author_rank: Super Contributor
timestamp: February 04, 2016, 04:09:14 pm
content: Quote from: Ian.M on February 04, 2016, 04:03:41 pm? can you explain ? it's pretty common to switch the power rail with a P-channel (with a body diode) ... i see nothing wrong there in the schematic.edit: i see where you coming from... you meant it will still powering the circuit through the body diode. - yes that right... it wil lpower the rest of the circuit with 2 diode drops.

author: bitshift
author_rank: Regular Contributor
timestamp: February 04, 2016, 04:15:58 pm
content: Thank you Ian. Another hole in my understanding of mosfets has just been filled. I completely ignored the diode in the mosfet symbol@rob77, the mosfet can only block current flowing from drain to source. When power is applied by the programmer, the source is at a higher potential than the drain and the body diode of the mosfet conducts. The rest of the circuit will be powered on as a result. This is not present in normal switching applications since another voltage is not applied.Now that we've established that this solution will not work, just for interest sake, what about the three questions?

author: Ian.M
author_rank: Super Contributor
timestamp: February 04, 2016, 04:23:49 pm
content: Actually, I expect it will work with D & S swapped. When powered from the 3.3V rail, initially the AVR would be powered via the body diode, but as soon as the source was above the gate threshold voltage, the MOSFET channel would start taking over, eventually shorting out the body diode for a low voltage drop. It will need 0.1uF decoupling after the MOSFET though.

author: rob77
author_rank: Super Contributor
timestamp: February 04, 2016, 04:41:28 pm
content: Quote from: bitshift on February 04, 2016, 04:15:58 pmi know how a mosfet works no worries.. but you're mixing up source and drainthe source of your P-chan is connected to 3V3 and the drain is connected to the VCC of the AVR... you're talking the opposite.Quote from: Ian.M on February 04, 2016, 04:23:49 pmyep, that would be a solution with a low Vgs threshold mosfet ( ~ 1V).

author: bitshift
author_rank: Regular Contributor
timestamp: February 04, 2016, 05:12:27 pm
content: Quote from: rob77 on February 04, 2016, 04:41:28 pmIndeed, thank you for pointing that outSo back to the questions, is this circuit solving a non existent problem?

author: Ian.M
author_rank: Super Contributor
timestamp: February 04, 2016, 05:35:26 pm
content: Quote from: bitshift on February 04, 2016, 03:43:48 pm1. Generally NO. While a small over-voltage of less than about 0.3V is unlikely to damage the chip. the ADC wont work properly if Aref>Vdd.2. If you can stand the voltage drop its the cheapest/simplest so is pretty common.3. Jumper for Vdd, or simply power the target externally so it doesn't need the programmer to power the board.

author: bitshift
author_rank: Regular Contributor
timestamp: February 04, 2016, 05:47:42 pm
content: Quote from: Ian.M on February 04, 2016, 05:35:26 pmThanks IanJust to make sure, powering the target externally would be like pulling the chip out, programming it, then sticking it back in?

author: Simon
author_rank: Unknown
timestamp: February 04, 2016, 06:07:09 pm
content: Hang on, what programmer are you using ? the AVRISPMK2 does not provide any power and other Atmel tools also don't. If anything you can't program your chip unless you power the board.

author: bitshift
author_rank: Regular Contributor
timestamp: February 04, 2016, 06:08:31 pm
content: I'm using aUSBasp.