0
\$\begingroup\$

I'm a novice hobbyist building a trivial circuit where an ATTiny 85 controls an RGB LED. In addition to the three PWM outputs, I have 2 inputs.

The first input is a potentiometer I'm using to set the maximum brightness of the LED. The second is a voltage divider where one of the resistors is a light-dependent resistor.

I'm running out of pins on the 8 pin IC so I have to use the SCK pin as an input. If I put the potentiometer on the SCK pin, the ICSP no longer works; however, if I put the output of the LDR voltage divider on the SCK pin, ICSP works fine.

How can I determine what's going on here so that I can make deliberate choices about pin use? Also, is there a common way to isolate the ICSP activity and during updates isolate the IC from the rest of the circuit?

\$\endgroup\$
  • \$\begingroup\$ turn the pot to half brightness and try again. \$\endgroup\$ – Jasen Nov 26 '18 at 10:21
2
\$\begingroup\$

In order to be able to program the chip, the programmer must be able to drive the pins that are input to the chip to their right digital levels, and the chip must be able to drive the pins that are output from the chip to their proper digital levels.

So, for example, the SCK is a signal generated by the programmer and read by the chip. For you to be able to program the chip, the programmer must be able to drive this line both high and low. If you have other components attached to this pin, then then the program must still be able to drive this pin high and low even with those components attached (and hopefully without frying those components in the process!).

In your case, it seems likely that you programmer is not able to drive the pin high and low with the potentiometer attached to it. If you look at that pin using a oscilloscope while you try to program the chip, you will likely see the voltage moving around some driven by the programmer, but the potentiometer is winning and the swings are not close enough to ground and Vcc for the chip to see them as the clock signal.

AI conventional solution might be to use a larger potentiometer if you are connecting the chip to the center tap. It will still work as expected when providing an input voltage to the pin, but because there is higher resistance between the pin and Vcc and ground, the programmer will be able to make wider voltage swings against it.

An unconventional solution is to give the programmer more powerful outputs using a buffer or a pair of transistors. This can help it generate larger voltage swings against the component that is attached to the pin, just be sure that component can take it. I once used this trick to be able to hang a bi-color LED off an IO pin and still be able to use the same pin for programming.

Another trick is to slow down the programming clock (i.e the -B parameter on AVRDUDE). This can help if there is a part attached to the programming pin that just slows down the voltage swings, like a capacity.

In the other direction of pins that the chip outputs to the programmer (like MISO), you are limited by the chip's drive capacity - but it is possible to still pick up even small outputs depending on what component is attached to the pin. You could, for example, use a pair of OP AMPs connected between the chip and the programmer to turn a small voltage movement in the center of the range into a digital one that the programmer can use.

Here is an application not from ATMEL that talks about this stuff, but only covers the conventional strategies...

http://ww1.microchip.com/downloads/en/appnotes/atmel-0943-in-system-programming_applicationnote_avr910.pdf

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.