Atmega32u4 arduino leonardo

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello friends, I'm having a trouble with the arduino leonardo.

I'm using avrdude to load into the micro a .hex file generated with AS6. So I'm using the board as a develpment one instead of using the arduino IDE.
First i didn't get it to work, until a realized that
when the arduino is in the bootloader section, it appears in a different com port compared with the port that apperas when it is in the "normal" section.

So after i realized that, i could get it to work uploading succesfully the .hex file.
So far so good, the simple code i uploaded to blinking the led work properly.

But then, when i connect the arduino to the pc, it does not get recognized!!!!
it only gets recognized if i press the reset button, and it appears for a few seconds (the time while its in the bootloader section, in fact it appears in the bootloader com port, but again just a few seconds)

I tried in different pcs, different usb cables etc..

then i tried to upload the blinking example from the arduino ide, just whent it was in the bootloader section. After a couple of tries and good timing, it could load the sketch before it disappers.

And now, the arduino its worknig normally, it gets detected again!!!

now i realized that it happens always that i upload an hex file generated with AS6.
The only way to fix it is uploading an arduino sketch quicly while its in the bootloader section.

What could be happening here? has anyone tried to upload an hex file to the leonardo insted of an arduino sketch??
Thanks in advance friends.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

When you build your code with AS6, are you including a USB library? If not, your leonardo won't respond to standard USB requests from the PC, so it won't get recognised as a USB device.

The arduino compiler automatically includes a USB library when it builds, which is why the PC does recognise it as a device.

Same thing for the bootloader, which is what you're seeing in that first few seconds after a reset.

- S

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the reponse mnehpets,
No I'm not using any USB library in AS6.
Can you please guide me?? I'm kind of newbbie,
If i include an USB library, what function should I use??
Should i put the device like a CDC class or something??
Thanks a lot friend.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Can you please guide me??

Go to the Extension Manager and from the "Gallery" select the LUFA" add on. Now when you create projects you can create from examples and some of those examples are LUFA USB projects. It should be easy to configure one to build for 32u4 and select one that implements CDC-ACM.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks clawson,
I'll give it a try,
Another question,I dont know if this is the right place to ask, if not please excuse me,
in the Arduino, when one uses some function like serial.write, is it actually using the USART of the micro or the USB port like a CDC-ACM?
if it uses the USB, why you can use the rx and tx signals?
If it uses the UART, why you can communicate throug the terminal monitor?

Thanks a lot friends.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Most Arduinos have a separate FTDI doing UART to USB-CDC conversion so the serial.write() is to the AVR UART then that converts onto the USB wires via the FTDI. However to reduce cost some later Arduinos are based on an AVR with USB built in. In that case serial.write() must be mapping directly to USB software/hardware in the AVR itself. Study the Arduino code to learn more.