0
\$\begingroup\$

I've start to build a project base on Atmega328 and I need to connect to it(via USB for availability of the USB port) for debugging (I prefer to debug it with serial communication), and I don't want to carry extra device(like FTDI module) around for debugging so I did search for how to do it .

It come to my understanding that I should use one of these solution:

  1. Use FTDI chip(like FT232RL or ...) on my PCB.
  2. Use one of the AVR MCUs with USB capability and get ride of any software or hardware convertor.
  3. Use a software USB to serial converter like what Arduino UNO did with ATmega16u2 by using LUFA library.
  4. Use V-USB to emulate USB connections.

first question: LUFA on USB-enabled devices

Why use LUFA on the chip which already have a USB capability (like at90usb162 and atmega8/16/32u2, as you can see on the LUFA example project)?

My assumption is that LUFA library helps to add software support to AVR which Don't have this kind of capability.

  • Am I wrong?
  • Does LUFA only work on the AVR which have D+,D-,UGND and UVCC pin on them?
  • Do those (USB) pins need extra hardware/software to work?

I know Atmega16U2 is super cheap but unfortunately my local supplier doesn't have it so it is off the table.

second question: secondary MCU alternatives

Could I use an AVR (one of those cheap types like atmega8a) as an intermediate device (to put between USB port and main Atmega328p), to not use main MCU resources and pins and it works as a software USB Serial converter,If there is, What code and schematic should I use or modify to do so? Is there any example to start with? I saw V-Bus example projects but nothing was near as what I have in mind.

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

first question.

My assumption is that LUFA library helps to add software support to AVR which Don't have this kind of capability.

From the LUFA documentation, first sentence:

LUFA is an open-source USB library for the USB-enabled AVR microcontrollers,

So, this is only working on the chips that have USB hardware. Having some hardware doesn't mean you can do something useful with it.

Just like having a motor doesn't mean you can drive safely.

second question.

Could I use an AVR (one of those cheap types like atmega8a) as an intermediate device (to put between USB port and main Atmega328p)

Sure, but then you might as well use any USB-Serial bridge ICs that exist and get away cheaper, and more importantly, without debugging your own USB/serial stack (probably without the appropriate tools for that).

FTDI aren't the only people who build such ICs, just the most expensive ones. There are | other | vendors (and many more).

But really, come on. You're making your project here much harder than it needs to be. You want a microcontroller that can talk to USB. So buy a microcontroller that can, and comes with code examples, and has enough compute power to still do your main task while communicating over USB.

In other words, ditch ATMega8/16, and use some cheap 32 bit microcontroller that has USB and, best case, has FreeRTOS or mbed support with full USB support.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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