Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
#!/bin/env python3
# Copyright (C) 2015-2017 Herbert Poetzl
import sys
import serial
import struct
from smbus import SMBus
from time import sleep
from icsp import *
tty = "/dev/ttyPS1"
ser = serial.Serial(
port = tty,
baudrate = 10000000,
bytesize = serial.EIGHTBITS,
parity = serial.PARITY_NONE,
stopbits = serial.STOPBITS_ONE,
# interCharTimeout = 0.2,
timeout = 0.01,
xonxoff = False,
rtscts = False,
dsrdtr = False);
def read16():
print("reading 16 words ...")
data = icsp_read_data(ser, 0x10)
print([hex(_) for _ in data])
def reset():
print("resetting address ...")
icsp_cmd(ser, b'[16!]', 0)
print(icsp_cmd(ser, b'Z')) # tristate MCLR (icsp)
print(icsp_cmd(ser, b'L')) # take MCLR low (icsp)
print(icsp_cmd(ser, b'#', 9)) # reset checksum
# print(icsp_cmd(ser, b'%', 5)) # reset stats
print(icsp_cmd(ser, b'[^]', 0)) # enter LVP
read16()
reset()
read16()
print("switching to config memory ...")
icsp_cmd(ser, b'[X0=]', 0) # switch to config mem
read16()
reset()
read16()
print(icsp_cmd(ser, b'#', 9)) # retrieve checksum
print(icsp_cmd(ser, b'Z')) # tristate MCLK (icsp)
9f4bea8acThis file is pinned to the selected release. Download the original to open it in your design tool.