Go Down

Topic: How does FT232 on Arduino work? (Read 3194 times) previous topic - next topic


I am a beginner of Arduino hardware. I am a little confused about the uploading sketch via Arduino USB. I know after clicking the Upload button, Arduino software would send something to FT232 before sending the sketch data, which forces DTR pin of FT232 to go low. Then the Arduino is reseted. And a piece of programme of bootloarder will run for several seconds. During this period, the schetch data is transmitted to Arduino. And after the uploading is done, i think Arduino would send back some data to Arduino software. So the software can display "Uploading done".
I guess FT232 will get DTR pin down while it receives some command via USBDM or USBDP. So my question is, before uploading the schetch data, what would Arduino software send to FT232? And what would be sent back from Arduino after the schetch data uploading is done?
Or maybe i am totally wrong about how it works.  ;D
Could someone explain it? Thanks


Or maybe i am totally wrong about how it works.

Well not totally but partially.

The DTR line is toggled by the USB driver and is used to reset the arduino. When an arduino first starts (or is reset) it looks for a signal from the serial port, if it doesn't get one it then the last sketch is run. If it does get one then it uploads the new sketch. This involves a few bytes back and forth through the serial port.
For the exact conversation see the source code of the boot loader.


This is an example of where the concept of "layering" is useful.  The FTDI implements a "serial port over usb"; both the avr chip on the Arduino and the programming software on your PC think they are talking to a serial port, and use standard operating system calls to send/receive data or manipulate the modem control signals.  The user does not have to worry about the exact commands sent on the USB wires at all.

As for what happens on the serial port: after the AVR chip is reset by the DTR toggle, it spends a couple moments looking for traffic on the serial port that looks like bootloader commands; if it sees them, it runs the bootloader and downloads new code.  If it doesn't, or if the bootload fails thereafter, it attempts to run whatever sketch is already in the AVR...   (This means that the Arduino doesn't send anything without provocation.  It only listens.)

Go Up