Page 1 of 2

download without ATN/DTR

Posted: 05 November 2008, 8:07 AM
by sturgessb
Hi Guys

Ive just been playing with the Xbee modules. I have two paired up and I connected one to the com1 tx, rx, atn pins of my zx-128ne, and the other to my pc.

When I powered it all up, i got gibberish through the debug window. Checked all the baud rates and this was all good (all set to 115200). So thought it must be the logic levels, so I toggled the rs232/logic level switch on the zx-128ne and rehooked the xbee up to pins 19 and 20. Hey presto, the serial output started coming through loud and clear.

Now the question... Is it possible to download new program files to the zx using this setup?

I tried keeping the dtr pin on the xbee hooked up to the ATN on zx but no joy.
So I then remembered reading about DTRless downloading, however all of the posts i can find on here seem to refer back to a time when there was not the built in option in the options of the IDE. I tried setting the ATN character to 4 in the IDE menu, but when i try to download it says it not responding, and then i get lots of giberish in the debug window again!

I cant find an app note or thread on how this is performed. Am i missing some documentation?

Cheers

Ben

Posted: 05 November 2008, 8:17 AM
by sturgessb
forgot to add that i have put the following in my code already (and flashed to device)

Dim ATNChar as Persistent Byte Based &H0013

and in the main()
ATNChar = &H04

and obviously set the ATN character to 4 in the options

Posted: 05 November 2008, 9:40 AM
by sturgessb
I think ive sorted it. Seeing as this solution might only be for VM not native mode, i put the following code in running as a task

Code: Select all

Public Sub cmdmodeTASK()
	If (GetQueueCount(CByteArray(Register.RxQueue)) > 0) Then
		tempbyte = Console.Read()
		if tempbyte = &H04 Then
			ZXCmdMode(True)
		end if
	End If
End Sub

This seems to do the trick, and i can invoke a download withought the DTR.

However. I can't seem to get this to work in FastMode so am I limited to using 19200 baud all the time? or can i get it to work in 115200?

Ben

Posted: 05 November 2008, 14:30 PM
by dkinzer
sturgessb wrote:I toggled the rs232/logic level switch on the zx-128ne and [...] the serial output started coming through loud and clear.
That is likely because the XBee has a non-inverted serial interface. Also, I believe that the XBee output is 3.3V so communication may not be completely reliable. Moreover, not all XBee devices have 5 volt tolerant inputs. You should check the specifications of the device that you have.
sturgessb wrote:I tried keeping the dtr pin on the xbee hooked up to the ATN on zx but no joy.
It may be that it can't keep up with the rate at which DTR is toggled. Some Ethernet-to-serial devices have the same problem. I've been experimenting with a Lantronix UDS1100 device that can download with DTR to native mode devices but not to VM devices. The timing for native mode devices is more relaxed than it is currently for VM devices.
sturgessb wrote:Seeing as this solution might only be for VM not native mode
The "ATN character" works for both VM and native mode devices. The Persistent Memory address for the ATN character is the same (&H13) in both types of devices as well. Of course, you have to first download the program that sets the ATN character before you can download without using DTR.
sturgessb wrote:I can't seem to get this to work in FastMode
I assume by this you mean calling ZXCmdMode() with a True parameter. Downloading is always done at 115.2K baud irrespective of the state of that parameter. The IDE's downloading procedure expects ZXCmdMode to be called with a False parameter because it attempts to communicate with the device initially at the standard speed.

Posted: 05 November 2008, 16:02 PM
by sturgessb
Don

The xbee im using says it has 5v friendly inputs so i think im ok on that.

I did try to use the ATN character in that address, and I did first download that in the conventional way, but still no joy. The only way i can get it working is with the additional task :(

you said that ' Downloading is always done at 115.2K ' but in the sysref manual it states ... 'if your application detects receipt of an “ATN character” and
then invokes ZXCmdMode() in slow speed mode, you can use the ZLoad command line utility or the
ZBasic IDE to perform downloading without needing to have DTR connected to the device.'.... Which to me implies downloading happens at 19.2k?

If it is 115,200 then I dont really understand a) why its not working, and b) what I have to do in order to keep comms at 115.2k and allow DTR less download.

Cheers

Ben

Posted: 05 November 2008, 16:32 PM
by dkinzer
sturgessb wrote:Which to me implies downloading happens at 19.2k?
The statement implies that some communication occurs at 19.2K but it doesn't say, that the downloading occurs at any particular speed.
sturgessb wrote:I dont really understand a) why its not working,
It doesn't work when you invoke ZXCmdMode() with a True parameter because the IDE expects the device to initially be at the slow speed. If it is not, then the IDE can't talk to the device to perform the download sequence (which includes, by the way, switching to high speed before commencing the download)
sturgessb wrote: and b) what I have to do in order to keep comms at 115.2k and allow DTR less download.
Is it that you also want serial communication with the device to be at 115.2K when you're not downloading?

Posted: 05 November 2008, 16:36 PM
by sturgessb
Ok good point.

Ive tried with False and its still no joy. As soon as i set the baud to 19200 it works.

Yes I would like normal comms to be at 115.2k also.

Posted: 05 November 2008, 17:19 PM
by dkinzer
sturgessb wrote:Yes I would like normal comms to be at 115.2k also.
OK, now I understand what the issue is. Stay tuned...

Posted: 05 November 2008, 17:31 PM
by sturgessb
standing by :)

Posted: 06 November 2008, 10:55 AM
by dkinzer
sturgessb wrote:Yes I would like normal comms to be at 115.2k also.
There was an issue with the process of changing the comm channel speed to perform the downloading and then restoring it. I believe that we've corrected the problem. You can try this experimental version v1.4.7 of the IDE. To use it, just extract the contents of the .zip file to the IDE subdirectory of the ZBasic installation directory (usually /Program Files/ZBasic/IDE). You might rename the existing ZBasicIDE.exe just in case you might want to revert to the previously installed version.

Posted: 06 November 2008, 18:38 PM
by sturgessb
sorry Don, still only works when set to 19200. double and triple checked it.

when set to 115200, i get 'Device failed to respond to ATN (4)'

Ben

Posted: 06 November 2008, 19:06 PM
by dkinzer
sturgessb wrote:still only works when set to 19200. double and triple checked it.
Odd, that. It works flawlessly here. I'm using the program below with the Serial Port Options of Port Speed=115200, 'Use ATN character' checked, and 'ATN Character' set to &H04. It is imperative that the parameter to ZXCmdMode() be False.
What version number do you see when you invoke Help | About ZBasic IDE

Code: Select all

Option SignOn Off

Dim atnChar as Persistent Byte Based &H0013

#if Option.TargetCode = "Native"
  Private Const stackSize as Integer = 200
#else
  Private Const stackSize as Integer = 50
#endif

Private Const cmdChar as Byte = &H04

Private taskStack(1 to stackSize) as Byte

'#define PERS_ATN

Sub Main()
#if defined(PERS_ATN)
  atnChar = cmdChar
#else
  atnChar = 0
#endif

  Call CloseCom(1, 0, 0)
  Call OpenCom(1, 115200, CByteArray(Register.RxQueue), CByteArray(Register.TxQueue))

#if NOT defined(PERS_ATN)
  ' launch the ATN detection task
  CallTask cmdTask, taskStack
#endif

  Debug.Print "Hello, world!"
End Sub

Sub cmdTask()
  Do
    If (StatusQueue(CByteArray(Register.RxQueue))) Then
      Dim c as Byte
      Call GetQueue(CByteArray(Register.RxQueue), c, 1)
      If (c = cmdChar) Then
        Call ZXCmdMode(False)
      End If
    End If
    Call Sleep(0)
  Loop
End Sub

Posted: 07 November 2008, 8:08 AM
by sturgessb
v1.4.7

compiler 2.6.4

Posted: 07 November 2008, 10:12 AM
by dkinzer
sturgessb wrote:when set to 115200, i get 'Device failed to respond to ATN (4)'
Is this the result when using the XBee device? If so, could you try it again using a standard serial port? There may be timing issues that need to be investigated.

Posted: 07 November 2008, 11:04 AM
by sturgessb
no this is using your TTL converter

Cheers

Ben