0

So, I programmed an ATMEGA32u4 and when I connect the device, it doesn't run the code. Instead, it gets recognised as an ATMEGA32u4 chip in Windows device manager.

To get the code running I have to open Atmel FLIP and open USB and then have to press the start application button after which it gets recognised as a HID in device manager and works as intended. I don't know why and what is happening.

The reset is pulled high with a 10k and the HWB is pulled down with a 10k and the chip has the factory bootloader on it.(if this helps)

  • Are you expecting Windows to receive some data from the ATMEGA32u4 system, or is there some other indication that the ATMEGA32u4 system is running (e.g. it has a heartbeat LED flash)? – Andrew Morton Jul 18 '21 at 20:03
  • If you are asking - if am expecting windows to receive some data during the bootup process, then no, after bootup, yes since it will be working as an HID. I have no indications for during bootup but after launching the application through FLIP the LEDs do light up for custom lighting and the inputs work. The device is a keyboard so it is pretty easy to discern if it is working or not just by shorting the switches. – Arya Kumar Sourav Jul 18 '21 at 21:24

1 Answers1

0

Pulling down HWB is what you do if you want to start the bootloader built into the ATmega32U4. It sounds like you want to run your own code instead of running the bootloader so you should pull HWB up, or disable the HWBE fuse.

David Grayson
  • 84,103
  • 24
  • 152
  • 189
  • Okay....how do i disable the HWBE fuse?(i know through isp but what bits exactly?) Also wont disabling the HWBE fuse prevent the chip from going into bootloader mode in the future? like I wont be able to flash it through USB anymore after disabling HWBE fuse, will I? – Arya Kumar Sourav Jul 19 '21 at 05:16
  • I mostly just program these chips through the ISP interface, not through the USB bootloader. If you are using the USB bootloader, then no, you wouldn't be interested in disabling the HWBE fuse, and you should pay more attention to the first part of my answer where I suggested pulling HWB up when you want your code to run. – David Grayson Jul 19 '21 at 16:55
  • Maybe you make a button that pulls HWB down when you press it, and you only use that when you want to program it. You also have to reset it while HWB is pulled down. It's up to you how to design your system. I think I answered your original question which was just "Why is the Atmega32u4 not running the code directly?" so please mark my answer as accepted. – David Grayson Jul 19 '21 at 16:57
  • this got solved thanks to you pointing out that HWB pulled down sends it into programmer mode. What I did was just set the BOOTRST fuse to 1 and HWBE to 0. (mentioned in the atmega32u4 docs at 27.5.2 and 27.5.3). And now with an internal code I can jump over to bootloader after reset via code. – Arya Kumar Sourav Jul 19 '21 at 19:26