serial communication using USB?

Hi

According to datasheet and application notes of AVRs, We can do serial communication (RS232) with just the following functions:

void InitUART(void);
void transmitByte(void);
ReceiveByte(void);



void main(void)

{

	InitUART(void);
	transmitByte('A');

}



void InitUART(void)

{

	...

}




void transmitByte(void)

{
	...

}




ReceiveByte()

{
	....

}

My question:

Is there any AVR application notes that tells you how to do serial communication using USB? I understand that USB is much more involved. But I was wondering if any body has some basic, small and understandable functions that allow communication using USB. Thanks

.

Doing USB in software is difficult, and the MCU can’t do much else. Atmel has an app. note on it.

Leon

leon_heller:
Doing USB in software is difficult, and the MCU can’t do much else. Atmel has an app. note on it.

Leon

How to do it in hardware then? I noticed that for RS-232, they always use MAX232 chip or something like that. Is there any chip to use? Thanks

You can throw on a logic level to USB converter chip on it. Popular ones are the FT232R from FTDI. It requires basically no external components and can work with 5V and 3.3V logic-level serial. In Windows/Linux/OS X it simply appears as another serial (COM) port.

theatrus:
You can throw on a logic level to USB converter chip on it. Popular ones are the FT232R from FTDI. It requires basically no external components and can work with 5V and 3.3V logic-level serial. In Windows/Linux/OS X it simply appears as another serial (COM) port.

What about software? Is any kind of programming invovled with this chip? Any example of it? Thanks

Regards

No software needed, it behaves to your microcontroller as a normal serial port. Same for the PC side.

Look at the datasheet (many example schematics), or SparkFun’s breakout modules for this chip.

There are MCUs with USB, like the PIC18F2450, and some AVRs. They aren’t difficult to use.

Leon