My code is for use with the XTAG ("XTAG1"), or any other FT2232-based device; it can
also be easily modified to work with anything else that drives JTAG (since that is
Interesting. I'll have to look deeper into that. Does the FT2232 have any logic, or it just passing bits straight through? That may be the shortest path to my goal.
It is a USB-to-bunch-of-pins converter: UART, SPI, JTAG, I2C, junk bus. It has
_some_ logic, mostly to do with timing; it handles the commands you send it.
It being USB, you send the commands in packets; you also have to read reply
packets, for those commands that return data (those that sample TDO). The
return buffers are fairly small, and you often need to see the result of some
JTAG transaction before you start the next; USB's structure limits you to 1kHz
to do that. The 2232 also has a maximum output frequency of 6MHz (when
using its JTAG output), and it is full-speed USB only (12Mbps). So, in total,
using a 2232 to drive JTAG has some gross inefficiencies, but it isn't _so_ bad,
and it works, and it is used all over the place :-)
How do you do that? It is hard to tell what (if anything) you are doing wrong, if
you don't tell us what you do :-)
Fair enough. ;) I found an interesting website that promised to make JTAG easy! (Uh Oh)
I followed their code along and duplicated it with my own ports and pins assigned. The site is http://www.fpga4fun.com/JTAG1.html
. I basically followed what I found there. Not completely useless, as I did get a device count, but the method they describe for getting ChipID's does not work for me today.
Maybe because it is incorrect :-)
Not all JTAG devices reset to IDCODE: some reset to BYPASS (with modern devices,
that is mostly when there are multiple JTAG devices in a single package). You can
see the difference because the (1-bit) BYPASS reg is initialised to 0, and the (32-bit)
IDCODE reg is initialised to have a 1 in the lowest bit.
Your example code does not handle BYPASS regs, but the xcore uses it.
Great! Now I can put the data capture from TDO in the correct part of the clock cycle and proceed from there.
TDI, TDO, TCK are all driven on the falling edge of TCK, and sampled on the rising
edge of TCK.
That explains it. I have not played with either of the resets yet, but give me about ten more minutes after I finish this post... :)
You can used the "five ones" method to do test-logic-reset, instead of TRST; _but_
you need to handle the TRST and RST signals properly at startup. If you do not,
the xcore's JTAG will not work.
Does your xcore run code? Often when your clock or reset stuff doesn't work
correctly, you get all zeroes on TDO.
Thanks, I'll watch for that. So far the chip is blank, as far as I know. The only one that has been programmed was done through an XTag port provided for that purpose, but it's multiplexed with six pins of a PGA, which I have been asked to write drivers for.
Okay, so you have an XSYS port, and using it you "see" the xcore? Excellent,
working stuff is always good :-)
You say your JTAG bus is multiplexed between the XSYS and the PGA. If I were
you, I would check (with a logic analyser or scope) if all the signals are handled
correctly (you can at least see if all signals are as they should be; you cannot
see the difference between open drain and push/pull with an LA, but just assume
it is okay, heh).
The first goal is for me to be able to load programs to the onboard XMOS chip
I think you want to take smaller steps ;-)
It is really OTP. You _can_ write to it over JTAG, but unless you do it on purpose
it just isn't going to happen :-)
You need to have more faith in my abilities! :) If it can be screwed up, I'll find a way!
I don't doubt that, but you are infinitely more likely to fry your chip with some
short-circuit (or whatever else stupid) first, way before you program the OTP (and
you can change almost all of the OTP contents to whatever you want anyway, if you
aren't going to boot from it -- just not the "boot from OTP" and "disable JTAG"
Writing to OTP is a quite complicated procedure. You really will not manage to
do so accidentally, it is not a chance of one in a million.