Showing posts with label ST-LINK. Show all posts
Showing posts with label ST-LINK. Show all posts

Sunday, April 12, 2020

Commodore 64 for STM32F429 Discovery board

So here is a Commodore 64 emulator I built for STM32F429 Discovery board:


Yeah, the LCD is tiny at 2.4", and the emulation runs about 15% slower than an NTSC C64.  But it's running on a small embedded board that's available for under $30 US (DigiKey, Mouser, ...) including mounted LCD display and USB OTG jack.  Just add keyboard, OTG USB adapter, and power supply.

This is a port of my portable C64/6502 emulator for terminal console, which was a port of my Commodore/6502 emulator for Windows Console.   But this time, I dropped the console part, and went for real video (LCD) and USB keyboard support.   Hello PETSCII!

Keyboard mapping (showing my Dell keyboard):
   STOP(ESC) F1 F2 F3 F4 F5 F6 F7 F8            Restore(PrtScr/SysRq) Run/Stop(Pause/Break)
             1! 2@ 3# 4$ 5% 6^ 7& 8* 9( 0) -_ += Del/Ins(Back)    Ins Hme/Clr     / * -
   Ctrl(Tab) Q  W  E  R  T  Y  U  I  O  P  [  ]  £ (\)            Del           7 8 9 +
             A  S  D  F  G  H  J  K  L  ;: '" Return(ENTER)                     4 5 6
   LShift    Z  X  C  V  B  N  M  ,< .> /?  RShift                     Up       1 2 3
   C=(Ctrl)           SPACEBAR              C=(Ctrl)              Lft Down Rt   0 .   Enter

Features:
  • 320x200 text screen on graphics LCD, with top/bottom border.
  • USB Keyboard (e.g. PC-103) support (symbolic, not positional)
    • Tab maps to C64 Ctrl key
    • Ctlr maps to C64 Commodore key
    • Esc key maps to C64 RUN/STOP key
    • PrtScr/SysRq maps to C64 RESTORE key (supports STOP+RESTORE)
    • PgUp also maps to C64 RESTORE key
  • Full 6502 emulation.  Go ahead, run some machine language on it.
  • Commodore character set
  • Text video at $0400 (address 1024)
  • Text color at $D800 (address 55296)
  • Keyboard scan by writing to $DC00, reading from $DC01
  • Full 64K RAM.  Update 2020-04-14: RAM/ROM/IO/Charset banking is implemented!  And 1K color nybbles
  • 1/60 second IRQ.  So we've got the software clock: TI, TI$
  • Upper/lower case switch ($D018), and reverse characters.
  • Border color ($D020) and background color ($D021).
Limitations:
  • Approximately 85% cpu speed of a real C64
  • No NMI.  No Restore key.  Update 2020-04-15: implemented, see keyboard above.
  • No other device support.  No tape, no disk, no serial, no cartridges, no joysticks, no printer.
  • VIC-II support is limited to getting system booted.
    • No full register support.
    • Text address can't be moved.
    • No graphics support.
    • No programmable characters.
    • No raster interrupts.
    • No sprites.
    • No left/right side border displayed.  Ran out of pixels.
  • No CIA1/CIA2 (except for keyboard data ports, but no data direction registers)
  • No SID.
  • In progress.  There are bugs lurking (for example, the IRQ and USB keyboard stops working exactly at 35 minutes, 38 seconds from start, maybe a resource leak in third party libraries, so we'll call that time limited I guess)
  • Keyboard support may need tweaks for more complete PETSCII key support
  • No CAPS LOCK or SHIFT LOCK supported
  • Doesn't utilize full capabilities of the STM32F429 MCU and discovery board components including 2.0MB of Flash (uses 110KB), 256KB of RAM (uses 83KB), 8MB SDRAM, motion sensor, user leds, user button, or other expansion capabilities.  Opportunity awaits!
Links:
Credit:  

Saturday, July 27, 2013

OpenOCD FT2232H based JTAG Adapter(s) with UART

USB to JTAG, and JTAG to JTAG adapters
JTAG adapters are commonly used to program and debug microcontrollers and microprocessors.  This circuit is a prototype of one that is compatible with OpenOCD which is an open source JTAG program and set of drivers.  The board and circuit presented here is simply a set of connections, jumpers, and sockets that leverage the FT2232H Mini Module as a USB to JTAG adapter. 

Four JTAG and/or SWD ports are provided for compatibility with a variety of development boards: 6-pin ST-LINK, 8-pin LPC-Link, 10-pin JTAG, 20-pin JTAG. 

Using one of two plug in modules, the 10-pin is either 0.05" pitch or 0.1" pitch. I plan to include both 10-pin formats on any revisions to this JTAG board so I can easily adapt between the formats.

When used as a USB JTAG adapter, only one of the JTAG or SWD ports is used.  Note that pin 1 is consistently in the upper left on this board.  Ribbon cables or socket cables are used to connect to the target board.  It is useful to have sets of cables that support all these pin-out formats.  Cables are quicker and easier than single conductor jumpers between individual connector pins.

An alternate use is to adapt from one pin-out to another when using other JTAG and/or SWD programmers.  In this case the mini module can be removed or simply disconnect the USB cable from the computer.  The board is only being used to convert pin-outs.  For example, I can use a 6-conductor socket to socket cable to connect the ST-LINK port to the ST-LINK socket on my STM32F4Discovery board, and then connect the LPC-Link socket via an appropriate cable to an LPCxpresso board.  I have used this method to program and debug my LPCxpresso board for LPC1343 with CooCox IDE.

Multiple JTAG adaptions are possible
  • ST-LINK to LPC-Link
  • ST-LINK to 10-pin
  • ST-LINK to 20-pin
  • LPC-Link to 10-pin
  • LPC-Link to 20-pin
  • 10-pin to 20-pin
  • 10-pin (1.27mm) to 10-pin (2.54mm) in future revision

Boards I was able to communicate with either with OpenOCD, ST-LINK, or CoLinkEx using the JTAG adapter(s) board include:

Caveats and Warnings.  Note that I did not do extensive testing.  I am not sure the RESET and RTCK lines are working.  Some boards I could only connect to using SWD instead of JTAG.  Driver installation and basic use of OpenOCD is not described in this post, so see Getting Started with OpenOCD.

Inspiration and References.  Most of the JTAG circuit is gleaned from multiple FTDI specifications regarding the FT2232H, Mini Module, and related MPSSE Basics Application Note AN_135.  And the circuit is very similar to the FLOSS-JTAG one shown here.


Under belly of the JTAG board
 

JTAG Schematic