Downloading without DTR (using ATNchar)

Questions and discussion about the ZBasic IDE.
Post Reply
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Downloading without DTR (using ATNchar)

Post by dkinzer »

Sometimes it is desirable or necessary to be able to download to a ZX device without using DTR to get the device into command mode. Usually, this situation will arise when using a serial communication link other than a hard-wire, e.g. BlueTooth. In some situations, the communication link cannot change speed dynamically so some special steps must be performed to configure both the application and the IDE for successful downloading.

To illustrate the procedure the list below enumerates the steps necessary to get DTR-less downloading working at a non-standard speed using a wired serial connection. Once that process is understood, adding a wireless connection will be simpler.
  1. Connect the serial port of the PC directly to the device (through level shifters), including the DTR signal.
  2. Configure the IDE to use DTR toggling for downloading (uncheck "Use ATN character" on the Serial Port Options dialog).
  3. Configure the IDE for the default execution baud rate of 19200.
  4. Compile and download the program below with the Option ConsoleSpeed directive commented out or set to 19200.
  5. Observe that the Debug window contains the signon message and the "Hello, world" output, confirming that Com1 baud rate is actually 19200.
  6. Uncomment the Option ConsoleSpeed directive in the test program and ensure that it is set to 9600. Recompile and download the modified program. (You may want to change the Debug.Print message to confirm that a new program has been downloaded.)
  7. Observe that the Debug window contains garbage text, indicating a baud rate mismatch (the device is now operating at 9600 baud but the IDE is still operating at 19200).
  8. Change the "Execution baud rate" in the IDE to 9600. Then, either reset the device (with a reset switch or using "Reset Device" on the Options menu) or just download again.
  9. Observe that the latest output in the Debug window is now correct. Note that the IDE's execution baud rate could have been changed before downloading the program containing a console speed change but this will only work correctly if you're using the DTR toggling download method.
  10. Disconnect the DTR signal from the device and, optionally, confirm that you can no longer download (Device failed to respond to ATN signal...).
  11. Configure the IDE for ATN Character downloading and ensure that the "Change speed for download" checkbox is unchecked.
  12. Attempt to download again and observe that it is successful (and that downloading is obviously slower than before - it's being done at 9600 baud) and the Debug window contains the expected output.
  13. Change the Option ConsoleSpeed value to 38400 but do not change the IDE's execution baud rate yet.
  14. Compile and download the program, observing that the download completes successfully but that the latest output in the Debug window is garbage.
  15. Now that the device is operating at 38400, change the IDE's execution baud rate to match. Download again and observe that the latest output in the Debug window is now correct.
The takeaway from this exercise is that when you're using ATN Character downloading, if you change either the ATN character or the ConsoleSpeed you must first download the modified program using the settings in the program that currently resides in the device. After the modified program is downloaded successfully you then must change the IDE to match the newly resident program in order to be able to download again.

Test Program:

Code: Select all

Option ATNChar &H04
Option ConsoleSpeed 9600

Sub Main()
    Debug.Print "Hello, world! 1"
End Sub
- Don Kinzer
Post Reply