avr & usb

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

Hi!

i am new to AVR development but have done some simple projects with gcc/jtag on OSX and things are looking good.

i would like to develop an altimeter for model airplanes and i would like to interface the module to the PC via USB. i am a bit lost when it comes to USB and was hoping someone here could point me in the right direction.

so far, i have been working with an atmega128 which doesn't have builtin USB. so i was looking at some of the AT90 models which do have USB.

would it be easier for me to work with an MC that has builtin USB or are there easy solutions to add native USB to a MC project?

any suggestions are welcome.
thanks,
-r

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

How about just giving your AVR an RS232 interface, and using a cheap USB-to-RS232 converter?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Has anyone bit-bashed a usb interface?

--

"If it wasn't for bad luck I'd have no luck at all"

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

Has anyone bit-bashed a usb interface? Yes, it has been done and discussed here - it used an overclocked '2313.

For a simple usb interface, I use the FTDI FT232RL chip which does USB->serial. Just load the driver and it looks like a serial port. Connect rx & tx signals to your uart on the AVR. USB without having to know about USB.

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

ok, thanks for the response. the FTDI chips look good and that seem pretty easy to do but i was wondering about "true" USB 2.0 for speed etc.

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

You'd probably be hard pressed to get more than full speed out of the avr in the first place. Full speed is (in theory) 12mb/s. Pushing data out of the avr that fast wouldn't leave much time for other processing. Unless you set up some kind of slave DMA-esque processor dedicated to transferring data from some external memory to USB.

Clancy _________________ Step 1: RTFM Step 2: RTFF (Forums) Step 3: RTFG (Google) Step 4: Post

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

clpalmer wrote:
... set up some kind of slave ... dedicated to transferring data from some external memory to USB.

Which is, of course, exactly what the FTDI et al chips do! 8)

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

At present the WinAVR GCC does not support the USB devices.

Keep it simple it will not bite as hard

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

But since you're developing on OSX, you're not using WinAVR. Maybe you've built the toolchain from scratch; Maybe you're using a distribution such as OSXAVR.

There are patches which do provide support for the AT90USBxxx devices. If you want to, it isn't particularly challenging to gather together and compile the toolchain manually, incorporating all of Jörg's latest patches for GCC, libc, bitnutils, etc.

IIRC, the initial OSXAVR package does include all the relevant patches for AT90USBxxx support.

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

awneil wrote:
Which is, of course, exactly what the FTDI et al chips do! 8)

Yes, but they're interfaced to the avr via a serial port. To get faster than full speed, you'd still need to be able to pump data out of the avr at >12mb/s, which is about as much as it can handle. I was more referring to something that shared a memory bus with the avr so the avr could set up a large block of data to be transferred and the slave "DMA" chip could just transfer directly from memory to USB at a high speed w/out needing the AVR.

Clancy _________________ Step 1: RTFM Step 2: RTFF (Forums) Step 3: RTFG (Google) Step 4: Post

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

Quote:

Yes, but they're interfaced to the avr via a serial port. To get faster than full speed, you'd still need to be able to pump data out of the avr at >12mb/s, which is about as much as it can handle. I was more referring to something that shared a memory bus with the avr

Well, yes and no.

AVR UART? Not necessarily. FTDI has flavours that do both serial & parallel.

PC/other host serial port? Not necessarily. FTDI has "native" drivers in addition to the virtual comm port.

Need DMA? Perhaps. But again, not necessarily. The FTDI chips have buffers so a block of data can be dumped via the parallel interface at a goodly rate. Face it: the AVR has a limited I/O bandwidth as you noted. I'd think a few readily-available blocks could be dumped pretty fast. The problem will arise on where the data is going to come from for a whole bunch of blocks.

The Atmel ARM SAM7S has the facilities that you describe. I haven't looked enough at the new AT90USB* (got my ATUSBKEY but have only exercised the demo program) to know if that AVR can meet the "dump a lot" criteria.

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

As someone who dabbles in model planes I know that weight reduction is the absolute key to onboard electronics. So I wouldn't even add the weight of the FTDI + USB connector to the board that goes on the plane. Instead just bring its UART output to some sort of (light!) header then use an off the shelf USB-RS232 interface for the PC (many of which are either based on the FTDI or Prologic chips anyway!)

Cliff

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

Quote:

Instead just bring its UART output to some sort of (light!) header then use an off the shelf USB-RS232 interface for the PC (many of which are either based on the FTDI or Prologic chips anyway!)

Or you can build the FTDI right into the plug-in adapter.

A cute thing about the Mega128/64: The fact that the UART0 pins are used for ISP is often (and rightfully IMO0 cursed. In this case, however, it can be helpful: The same "access port" (through holes, header, edge connector, whatever) that are used for ISP can also be used to hook up serial interface adapters. The ISP typically has Vcc, Gnd, /RESET, TX0, RX0, & SCK. So, skip the /RESET. Vcc & Gnd can be used to power the adapter thingy (USB, RS232, RS485, whatever), there is access to UART0, and an extra signal for RS485 TE or LED or whatever.

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

> At present the WinAVR GCC does not support the USB devices.

If you're referring to the AT90USBxxx devices, that's just wrong.
They are fully supported by WinAVR-20060415.

The only thing that's not supported by WinAVR-20060415 is to connect
avrdude to the JTAG ICE mkII or AVRISP mkII through USB. (The tools
do support it, but that WinAVR's version hasn't been compiled against
libusb.)

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.