Skip to content

Instantly share code, notes, and snippets.

@flatz
Forked from elfmimi/XC2C64-Blink-Test.ctl
Created November 6, 2022 00:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flatz/1bd02ecf684874fa37da0e723bb6fc6b to your computer and use it in GitHub Desktop.
Save flatz/1bd02ecf684874fa37da0e723bb6fc6b to your computer and use it in GitHub Desktop.
JTAG Boundary-Scan Examples for OpenOCD
# OpenOCD script to demonstrate JTAG Boundary-Scan I/O
# It will update the state of LED connected to Pin34 according to
# input from SW1 (Pin30) and SW2 (Pin29) .
# Supports CR2DIP CPLD lerning kit. ( XC2C64 and XC2C64A )
# See xc2c64_vq44.bsd or xc2c64a_vq44.bsd
#
# Invoke it like this:
# openocd -f interface/ftdi/openocd-usb.cfg -f XC2C64-Response-Test.ctl
adapter speed 1000
transport select jtag
jtag newtap xc2c64 bs -irlen 8 -ignore-version -expected-id 0x06c5e093 -expected-id 0x06e5e093
init
# IDCODE
irscan xc2c64.bs 1
if ![string match ?6\[ce\]5\[89abcdef\]093 [drscan xc2c64.bs 32 0x00000000]] {
error "Unexpected IDCODE"
}
# SAMPLE/PRELOAD
irscan xc2c64.bs 3
set sample [drscan xc2c64.bs 192 0x000000000000000000000000000000000000000000000000]
# EXTEST
irscan xc2c64.bs 0
while true {
set sw1 [expr (0x[string range $sample 9 9] & 8) ? 0 : 1]
set sw2 [expr (0x[string range $sample 12 12] & 8) ? 0 : 1]
# echo "$sw1 $sw2"
if [expr ($sw1 ^ $sw2)] {
set send_data 0x000000200000000000000000000000000000000000000000
} else {
set send_data 0x000000600000000000000000000000000000000000000000
}
set sample [drscan xc2c64.bs 192 $send_data]
# sleep 100
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment