Skip to content

Code-And-Go Goes From No-Go to Bingo!

March 4, 2016

Below is the bootload sequence for the 1802 Olduino.  The top line is RTS which resets the olduino.  First you see RTS cycle a couple of times due to the MODE command. Then you see RX and TX going as the bootloader runs.  Finally, two seconds after the RX activity stops, you see TX running as the 1802 prints “Hello World”.
16-03-04 hello 1802

MODE com3: rts=on >NUL

AVRDUDE -CC:\…/avrdude.conf -u -V -D -patmega644p -cstk500v1 -P\\.\COM3 -b57600 -U flash:w:%1.hex:i %2 %3

Next is what should be the equivalent sequence for the Olduino/Z (although it’s still connected to the 1802). Here you see RTS cycle then it goes low for the full duration of the xmodem transfer(which doesn’t actually happen) then go high again. You see the 1802 sending the “Hello..” sequence near the beginning and again after RTS comes high. This is not what I want.

mode+xmodemfailto1802

MODE com3: rts=on >NUL

c:\apps\python27\python C:\Users\bill\Documents\python\xmonly.py

 

 

Then is the trace of just doing a pyserial open and close – this is clearly what is lowering and raising the RTS line.  I need to deal with that or move away from python.

16-03-04 pyopenclose1802

port = serial.Serial(port=’COM3′, parity=serial.PARITY_NONE,
bytesize=serial.EIGHTBITS,
stopbits=serial.STOPBITS_ONE, timeout=5,xonxoff=0,
rtscts=0,dsrdtr=0,baudrate=9600)

port.close()

 

And Bingo! Thanks to an answer on Stack Overflow I modified the python serial open sequence to stop it activating RTS. The result seems perfect. You see the RTS cycle at first, then the XMODEM load sequence, then the Hello World app gets run so the TX line shows activity again.

16-03-04 and bingo

 

import logging
logging.basicConfig()
import serial
try:
    from cStringIO import StringIO
except:
    from StringIO import StringIO
from xmodem import XMODEM, CRC
from time import sleep
import os
fileSize=os.path.getsize('C:\\Users\\bill\\Documents\\olduinoz\\z88dk\\helloworld\\a_code.bin')
print "File Size is",fileSize

def getc(size, timeout=1):
    return port.read(size)
xCount=0
def putc(data, timeout=1):
    global xCount
    xCount=xCount+1
    port.write(data)
    print("TX# %d(%d)" % (xCount,len(data)))
    sleep(0.001) # give device time to send ACK

#Main program starts here - define the serial port, set RTS off, then open it
port = serial.Serial(parity=serial.PARITY_NONE,
                     bytesize=serial.EIGHTBITS,
                     stopbits=serial.STOPBITS_ONE,timeout=5,xonxoff=0,
                     rtscts=0,dsrdtr=0,baudrate=9600)
port.rts=False
port.port='COM3'
port.open()
#open the file to be loaded
stream = open('C:\\Users\\bill\\Documents\\olduinoz\\z88dk\\helloworld\\a_code.bin','rb')
#transfer the file
result=XMODEM(getc, putc).send(stream, quiet = 1)
#close the file
stream.close()
#close the port
port.close()
if result:
    print "transfer successful"
else:
    print "transfer unsuccessful"

 

Advertisements

From → Olduino/Z

One Comment

Trackbacks & Pingbacks

  1. Code And Go! Olduino/Z is Styling Now! | olduino

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: