Hi, I am experimenting with the Arduiono Uno and Arduino Nano. At the moment I am trying to communicate from the PC to the Arduino over the serial port. But I want to understand the underlying procedure completely. So far I found in the documentation the Arduino is doing the following steps after a reset.
- Run the bootloader.
- Looking for an limited amount of time for a new sketch on the serial port.
- If a sketch is available burn it into the flash memory.
- Run the sketch.
After reading more information about PC to Arduino communication and also making some experiments I found out the following about the Arduino Nano.
- The board contains an FT232RL to translate USB and Serial communication.
- The ATMEGA gets reset if DTR is going LOW.
- If I open a communication session the ATMEGA gets reset (e.g. open the Arduino IDE Serial Monitor).
Now I got some questions about it.
I am not sure but is this the bootloader for the Uno & Nano ?
If I open a serial connection to the Arduino and transmit some data immediately, the Arduino gets reset and looking for a new sketch. Is this dangerous because the bootloader could mistakenly interpret the data as a new sketch? So I have to wait a moment, until the sketch is starting and setup the UART peripheral again, before send some data?
What exactly makes the FT232RL assert DTR LOW and what exactly happens if I open the serial monitor? Why if I run the following C# program the Arduino gets only reset the first time and after restarting the C# program the Arduino is not resetting anymore until I disconnect and connect the USB plug again?
SerialPort lSerial = new SerialPort("COM4", 9600); // , Parity.None, 8, StopBits.One Console.WriteLine("Press enter to open connection..."); Console.ReadLine(); lSerial.Open(); Console.WriteLine("Connection opened."); Console.WriteLine(); Console.WriteLine("---"); Console.WriteLine(); Console.WriteLine("Press enter to close connection..."); Console.ReadLine(); lSerial.Close(); Console.WriteLine("Connection closed."); Console.WriteLine(); Console.WriteLine("---"); Console.WriteLine(); Console.WriteLine("Press enter to exit..."); Console.ReadLine();
Can I use the Win32 API (e.g. CreateFile) with C++ to communicate with the Arduino?