1
\$\begingroup\$

I have managed to put micronucleus bootloader on an ATtiny85. Using it, I can successfully upload programs to my ATtiny through USB and they run as they should, as long as they are connected to USB. When I only connect the Tiny to +5V and GND, it does not run the program. How can I change that? How can I make it so that my programs run even without connecting the ATtiny85 to USB?

\$\endgroup\$

2 Answers 2

2
\$\begingroup\$

The bootloader should exit and run the user program after 6 seconds if USB is not connected. If that is too slow then you can recompile with a shorter delay, or set AUTO_EXIT_NO_USB_MS >1.

If the user program doesn't appear to be running after the timeout period then you probably have some other problem. Perhaps your program has a bug that stops it from working properly if the bootloader doesn't communicate with the USB port first (check for uninitialized variables, hardware registers not being set to defined states etc.).

Also, if the board is powered by the USB port when plugged into it then make sure that your external power supply is good enough to run it stand-alone.

(in bootloaderconfig.h)

/*
 * Define bootloader timeout value. 
 * 
 *  The bootloader will only time out if a user program was loaded.
 * 
 *  AUTO_EXIT_NO_USB_MS        The bootloader will exit after this delay if no USB is connected.
 *                             Set to 0 to disable
 *                             Adds ~6 bytes.
 *                             (This will wait for an USB SE0 reset from the host)
 *
 *  AUTO_EXIT_MS               The bootloader will exit after this delay if no USB communication
 *                             from the host tool was received.
 *                             Set to 0 to disable
 *  
 *  All values are approx. in milliseconds
 */

#define AUTO_EXIT_NO_USB_MS    0
#define AUTO_EXIT_MS           5000

 /*
\$\endgroup\$
10
  • \$\begingroup\$ Thanks for the answer! I seem to have localized the problem a bit more: It doesn't need to be connected to USB, however, I cannot program the tiny through USB and then move it somewhere else, the ATtiny needs to be connected to the same components I used to program it. I used this schematic to wire the USB interface for the tiny, it needs to remain connected to those resistors and diodes. Hopefully you understand what I mean: I cannot use the USB connection to just program the tiny, it needs to stay there in order to work. \$\endgroup\$
    – Calin
    Oct 28, 2014 at 17:09
  • \$\begingroup\$ Is there any way I can change that? \$\endgroup\$
    – Calin
    Oct 28, 2014 at 17:10
  • \$\begingroup\$ I fixed it. Apparently, that pull-up, resistor needs to remain connected to the D- pin on the ATtiny, that is PB3. \$\endgroup\$
    – Calin
    Oct 28, 2014 at 17:14
  • \$\begingroup\$ Well, can I somehow get rid of that pull-up? It's interfering with my circuit. \$\endgroup\$
    – Calin
    Oct 28, 2014 at 18:16
  • \$\begingroup\$ What circuit do you have connected to pin 2? \$\endgroup\$ Oct 28, 2014 at 20:00
1
\$\begingroup\$

So, in order to make the ATtiny work even after disconnecting it from USB, you need to leave pin 3 (PB3) on the ATtiny connected to +5V through a pull-up resistor.

\$\endgroup\$
1
  • \$\begingroup\$ thank you! this was what I was missing - didn't find much info on the net anywhere - everyone know how to flash the bootloader but none talked about disconnecting after. so I am happy to have finally found the missing piece! (only took 2 nights of searching this time to fix the problem haha) \$\endgroup\$ Dec 5, 2019 at 7:10

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.