Downloads and Links


KiCAD Project Files

I publish all the KiCAD project files, you can either directly use the project files or you can also modify it in case you want to change e.g. the SD-Card cage or USB connector.

Here you can download the KiCAD Project Files

CPLD Files

CPLD Design Files

The CPLD design files are the source code of the CPLD equations. The MSCP emulator has two CPLDS, one ATF1504 and one ATF1508. Here you can download the

CPLD Design File QBUSEMUDMA.PLD for the ATF1504

and the

CPLD Design File QBUSEMUMAIN.PLD for the ATF1508

CPLD Chain File

As the CPLDs are programmed via the JTAG interface you can have more than one CPLD connected to the same JTAG interface and program them individually or all at once. For this you need a description of your CPLD daisy chain, you need in fact a chain file even when you have only one CPLD, which describes the order of the CPLDs, the type of each and the action to be executed on each CPLD. This chain file can be created using ATMISP and each hardware project requires is specific chain file of course. Note that the chain file includes absolute file names, therefore before using my chain file you probably might need to change the path to each JEDEC file. Just open the chain file and double click on each CPLD and browse to the location where your JEDEC files are stored.

Chain File used by ATMISP

CPLD JEDEC Files

You need the JEDEC files to program the CPLDs. Either you compile the design files with WinCUPL or the cupl.bat file or just use the following JEDEC files

JEDEC File QBUSEMUDMA.jed for the ATF1504

JEDEC File QBUSEMUMAIN.jed for the ATF1508

Microcontroller Firmware

I use an older version of avrasm2, which was once available for macOS. Surprisingly this is a 64-bit command line programm and therefore still works on current Mac as long as macOS includes the run time environment to emulate the Intel architecture, aka Rosetta 2.

Main Source Code

The main source code can be downloaded as compressed folder. Download and expand the source code into it’s own folder into which you have also to download and expand the standard include files I provide below.

A Makefile is included which can be used to assemble the source code, provided you have installed the necessary toolchain that includes make.

Also avrasm2 must be installed and available as command line tool. For Windows users you need to install Microchip Studio and place the avrasm2.exe into you path, respectively add the folder where Microchip Studio has placed avrasm2 part of your calling path. macOS users can either use the macOS version once available or install wine and extract avrasm2.exe from a Microchip Studio installation.

MSCP Emulator Source Files

My Own Include Files from my own Library

In the last couple years I have done quite a bit of programming with AVR microcontrollers, all in assembler, my favorite language when interacting with real hardware. And obviously a set of standard functions and modules have been created which are now included in many of my projects. For example

  • For debugging purposes I have translated the Apple II monitor into a AVR source code module that provides a interface to the AVR memory.
  • To parse command lines I have translated T$PARS form the MACRO-11 into a set of macros and function called tparse.
  • To read FAT-16 and FAT-32 formatted partitions I have created a set of functions to standardise the way how to read files and in case of disk image files also to write to the files.
  • Very often you need to print messages including numbers and so I have created my own limited version of printf().
  • And last but not least I have started to use my own small RT-OS in all my projects as it makes running parallel jobs much easier than having to integrate some sort of cooperative scheduler, this also includes a RT-OS compatible version of malloc() and free() to allocated and dispose memory dynamically

All these modules are perfect, but they do their job. Over the past years I have started to implement the ABI (Application Binary Interface) for some of the modules and I plan to convert all modules to implement the standardised application interface, the long time goal is to switch from legacy avrasm2 to the gnu toolchain using gcc assembler and compiler.

Make sure that the include folder and the MSCPEmu-v4-0 folder are in the same directory.

MSCP Emulator Source Files

Firmware

Here you can download the HEX file which you can be directly used to program the microcontroller using an UPDI programmer

HEX File of the Firmware for the Microcontroller

Tools

KiCAD

The schematic and the circuit board were designed using KiCAD. KiCAD is an open source EDA tool and can be used free.

The Open Source EDA Tool KiCAD

WinCUPL

You can use WinCUPL to compile the design files and generate the necessary JEDEC files to program the CPLDs. Recently Microchip has updated the legacy WinCUPL program and now provides WINCUPL II which now also supports Windows 11. You need to install this tool if you want to compile the CPLD design files. If you want to use the GUI you need to create a new project and import the design files linked below and then import the design files into the project. The format of project files has completely changed sind the old legacy WINCUPL version. Note that even if you do not plan to use the GUI you still need to install WINCUPL II if you want to compile the design files using the command line tools, like cupl.exe and the various fitters.

Microchip WINCUPL II

Note the built-in editor of source files in WINCUPL does only recognise text files in Windows format, e.g. with carriage return / line feed after each line. It does not like Unix or legacy MacOS style textfiles. The command line tools however don’t care.

The CUPL language by the way not only supports the Microchip CPLDs but as well legacy GALs. In addition Microchip still provides their own version of devices compatible to GALs which makes WinCUPL even more useful. Although the programming algorithm of these devices is proprietary there are now cheap programmers available that officially support the programming of these devices like the ATF22V10 or ATF16V8.

In my case I use a XGecu T48 programmer and the minipro program to program GALs.

cupl.bat

Because I use a Mac to develop all my source code I also use the Mac to edit and maintain the CPLD design files, which are just text files. To compile the design files into JEDEC files I use a Windows BATCH file instead of the WinCUPL GUI. You still need to install WinCUPL as the batch file makes use of the CUPL compiler and the FITTER programs that are used to convert the design files into JEDEC files. The following batch file is a nice wrapper for the CUPL and FITTERs command line tools.

Adrien Kohlbecker’s batch file to compile CUPL designs

ATMISP

To program the CPLD I use the official ATIPS program from Microchip. You can download ATMISP and many other PLD Design Resources from

Microchip PLD Design Resources

AVRASM2

For Windows users you can use Microchip Studio. Microchip Studio comes with all necessary include files for the various existing AVR microcontrollers as well with the assembler AVRASM2.

Note that Microchip no longer recommends Microchip Studio for new developments and especially does not recommend AVRASM2 assembler for new projects. E.g. there is no AVRASM2 assembler included in the MP Lab X IDE anymore.

You can still download older versions of MP Lab X IDE and the XC8 compilers. XC8 extension to MP Lab X IDE up to version 2.10 for MacOS and Linux include a Mac and Linux version of AVRASM2. That’s the one I use. If you still own an old Mac supporting 32-bit applications, e.g. macOS Mojave, then you can download old versions of MP Lab X IDE and the XC8 extension and extract the binary of avrasm2, which still runs perfectly on new macOS systems.

Note that the AVRASM2 throws a warning when using the standard include files for the new AVR microcontrollers family. You can ignore the warning regarding unknown core type V4S, this is simply caused by the following defintion.

#pragma AVRPART CORE CORE_VERSION V4S

I simply use a modified includ file where I replaced the core version V4S with V2E. This mostly affects the debugger and the list of valid instructions.

Microchip Studio

Microchip still provides Microchip Studio for legacy projects. It is the only officially supported tool that still includes the original avrasm2 assembler.

Microchip Studio for AVR® and SAM Devices

Running avrasm2.exe on macOS

You can also use wine to run avrasm2 from Microchip Studio

Install wine

You first need to install wine

peter@MacBook-Air-von-Peter MSCPEmu-v4-0 % brew install --cask  wine-stable                
==> Would install 1 cask:
wine-stable
==> Would install 1 dependency for wine-stable:
gstreamer-runtime
==> Do you want to proceed with the installation? [y/n]
==> Fetching downloads for: wine-stable
✔︎ Cask wine-stable (11.0_1)                                                                                                                                                                  Verified    185.3MB/185.3MB
==> Caveats
wine-stable is built for Intel macOS and so requires Rosetta 2 to be installed.
You can install Rosetta 2 with:
  softwareupdate --install-rosetta --agree-to-license
Note that it is very difficult to remove Rosetta 2 once it is installed.

==> Installing dependencies: gstreamer-runtime
==> Caveats
This cask installs the GStreamer.framework runtime tools into /Library/Frameworks/

To install the GStreamer.framework development tools also, run:
  brew install --cask gstreamer-development

==> Downloading https://gstreamer.freedesktop.org/data/pkg/osx/1.28.4/gstreamer-1.0-1.28.4-universal.pkg
######################################################## 100.0%
==> Installing Cask gstreamer-runtime
==> Running installer for gstreamer-runtime with `sudo` (which may request your password)...
Password:
installer: Package name is GStreamer 1.0
installer: Installing at base path /
installer: The install was successful.
🍺  gstreamer-runtime was successfully installed!
==> Installing Cask wine-stable
==> Moving App 'Wine Stable.app' to '/Applications/Wine Stable.app'
==> Linking Binary 'appdb' to '/opt/homebrew/bin/appdb'
==> Linking Binary 'winehelp' to '/opt/homebrew/bin/winehelp'
==> Linking Binary 'msidb' to '/opt/homebrew/bin/msidb'
==> Linking Binary 'msiexec' to '/opt/homebrew/bin/msiexec'
==> Linking Binary 'notepad' to '/opt/homebrew/bin/notepad'
==> Linking Binary 'regedit' to '/opt/homebrew/bin/regedit'
==> Linking Binary 'regsvr32' to '/opt/homebrew/bin/regsvr32'
==> Linking Binary 'wine' to '/opt/homebrew/bin/wine'
==> Linking Binary 'wineconsole' to '/opt/homebrew/bin/wineconsole'
==> Linking Binary 'winedbg' to '/opt/homebrew/bin/winedbg'
==> Linking Binary 'winefile' to '/opt/homebrew/bin/winefile'
==> Linking Binary 'winemine' to '/opt/homebrew/bin/winemine'
==> Linking Binary 'winepath' to '/opt/homebrew/bin/winepath'
==> Linking Binary 'wineserver' to '/opt/homebrew/bin/wineserver'
==> Linking Binary 'wineboot' to '/opt/homebrew/bin/wineboot'
==> Linking Binary 'winecfg' to '/opt/homebrew/bin/winecfg'
🍺  wine-stable was successfully installed!
==> Caveats
==> wine-stable
wine-stable is built for Intel macOS and so requires Rosetta 2 to be installed.
You can install Rosetta 2 with:
  softwareupdate --install-rosetta --agree-to-license
Note that it is very difficult to remove Rosetta 2 once it is installed.
==> gstreamer-runtime
This cask installs the GStreamer.framework runtime tools into /Library/Frameworks/

To install the GStreamer.framework development tools also, run:
  brew install --cask gstreamer-development
peter@MacBook-Air-von-Peter MSCPEmu-v4-0 % 

As you can see this comes with some caveats.

The first time you execute wine as a command you will get an error message regarding unknown source of the program and because it is not officially singed you have to allow it using System Settings.

Also you need to run winecfg once using the terminal window.

Extract and Copy avrasm2.exe

Next you need to install Microchip Studio 7.0 on a windows machine and copy the following files to your Mac.

C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avrassembler\avrasm2.exe

and the folder with the AVR include files

C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\AVR-Dx_DFP\1.10.114\avrasm\inc

In my case I have copied the files to a folder named avrasminclude which is as well in the folder containing the folder with the source code and the include folder with my standard source files. As an example here is the tree of all files required on my Mac. Not all include files from Microchip Studio are shown here.


.
├── avrasm2.exe
├── avrasminclude
│   ├── AVR128DA28def.inc
│   ├── AVR128DA32def.inc
│   ├── AVR128DA48def.inc
│   ├── AVR128DA64def.inc
│   ├── AVR128DB28def.inc
│   ├── AVR128DB32def.inc
│   ├── AVR128DB48def.inc
│   ├── AVR128DB64def.inc
│   ├── AVR32DA28def.inc
│   ├── AVR32DA32def.inc
│   ├── AVR32DA48def.inc
│   ├── AVR32DB28def.inc
│   ├── AVR32DB32def.inc
│   ├── AVR32DB48def.inc
│   ├── AVR64DA28def.inc
│   ├── AVR64DA32def.inc
│   ├── AVR64DA48def.inc
│   ├── AVR64DA64def.inc
│   ├── AVR64DB28def.inc
│   ├── AVR64DB32def.inc
│   ├── AVR64DB48def.inc
│   ├── AVR64DB64def.inc
├── include
│   ├── FAT
│   │   ├── BuildFragList.asm
│   │   ├── Cluster2Sector.asm
│   │   ├── CopyName.asm
│   │   ├── CreatePath.asm
│   │   ├── FAT-defs.asm
│   │   ├── FAT-library-v2-0.inc
│   │   ├── FreeList.asm
│   │   ├── LinkedCluster.asm
│   │   ├── Logical2Physical.asm
│   │   ├── MatchFileName.asm
│   │   ├── Name2DirEntry.asm
│   │   ├── OpenDir.asm
│   │   ├── ReadDir.asm
│   │   ├── ReadFileByte.asm
│   │   ├── ReadFileClose.asm
│   │   └── ReadFileOpen.asm
│   ├── macro-library-v1-2.asm
│   ├── malloc-v3-0.asm
│   ├── monitor-chartbl-v2-0.inc
│   ├── monitor-subtbl-v2-0.inc
│   ├── monitor-v2-0.asm
│   ├── monitor-v2-0.inc
│   ├── mprint-v1-0.asm
│   ├── nrf24.inc
│   ├── nrf24m.asm
│   ├── nrf24mprint.asm
│   ├── print-v2-1.asm
│   ├── print-v2-1.inc
│   ├── printf-v2-0.asm
│   ├── readcmdline.asm
│   ├── rtos-v3-0.asm
│   ├── rtos-v3-0.inc
│   ├── rtos-v3-0.txt
│   ├── SD-Card-IO-v2-0.asm
│   ├── tparse-v2-0.asm
│   ├── tparse-v2-0.inc
│   └── tparse-v2-1.asm
├── MSCPEmu-v4-0
│   ├── ABI-Register-Convention.txt
│   ├── changelog-qbus.txt
│   ├── CLI-action.asm
│   ├── CLI-attach.asm
│   ├── CLI-commands.asm
│   ├── CLI-data.inc
│   ├── CLI-directory.asm
│   ├── CLI-disasm.asm
│   ├── CLI-dumpblock.asm
│   ├── CLI-fdisk.asm
│   ├── CLI-logging.asm
│   ├── CLI-partition.asm
│   ├── CLI-sdcard.asm
│   ├── CLI-show.asm
│   ├── CLI-status.asm
│   ├── CLI-sub.asm
│   ├── CLI-table.inc
│   ├── control-blocks.inc
│   ├── crash.asm
│   ├── CRC-Tables.inc
│   ├── diskemu.inc
│   ├── Dismountvolume.asm
│   ├── DMA-Macro.inc
│   ├── documentation.txt
│   ├── DriveTab.inc
│   ├── DUBOOT.LST
│   ├── DUBOOT.MAC
│   ├── DUBOOT.OBJ
│   ├── DUTEST.LST
│   ├── DUTEST.MAC
│   ├── error.inc
│   ├── help.inc
│   ├── main-v2-1.lss
│   ├── main-v2-1.map
│   ├── main-v2-1.obj
│   ├── main-v2-1.tmp
│   ├── main.asm
│   ├── main.hex
│   ├── main.inc
│   ├── main.lss
│   ├── main.map
│   ├── main.obj
│   ├── main.tmp
│   ├── Makefile
│   ├── Messages.inc
│   ├── monitor-sub.asm
│   ├── Mountvolume.asm
│   ├── mprint.asm
│   ├── MSCP
│   │   ├── _ccb.inc
│   │   ├── _data.inc
│   │   ├── _defs.inc
│   │   ├── _dup.inc
│   │   ├── _mscp.inc
│   │   ├── _pcb.inc
│   │   ├── _pkt.inc
│   │   ├── clear.asm
│   │   ├── description.inc
│   │   ├── disk.asm
│   │   ├── doabo.asm
│   │   ├── doap.asm
│   │   ├── doavl.asm
│   │   ├── dogcs.asm
│   │   ├── dogus.asm
│   │   ├── doonl.asm
│   │   ├── doother.asm
│   │   ├── doplf.asm
│   │   ├── dorw.asm
│   │   ├── doscc.asm
│   │   ├── dosuc.asm
│   │   ├── douna.asm
│   │   ├── dup.asm
│   │   ├── init.asm
│   │   ├── poll-v2-0.asm
│   │   ├── qbus-v2-0.asm
│   │   └── subsm.asm
│   ├── portdefs22b.inc
│   ├── portdefs22c.inc
│   ├── portdefs40.inc
│   ├── portdefs40qbus.inc
│   ├── portdefsqbus51.inc
│   ├── portdefsqbus64.inc
│   ├── qbus-v2-0.asm
│   ├── radonlydata.asm
│   ├── readinit.asm
│   ├── rlv12-v2-0.asm
│   ├── rlv12-v2-0.inc
│   ├── scanjob.asm
│   ├── SD-Card-Multiple-v1-0.asm
│   ├── SD-Card-Print-v1-0.asm
│   ├── SD-Card-Turbo-v1-0.asm
│   ├── SD-Card-v1-0.asm
│   ├── sdcardjob.asm
│   ├── seekjob.asm
│   ├── serial1.asm
│   ├── serial1.inc
│   ├── sram.bin
│   └── strings.inc

Set your environment variable MVK_CONFIG_LOG_LEVEL=0. This suppresses a lot of information printed by wine each time you invoke the command line.

I have added the qbusw rule to the Makefile, which is part of the source code archive, to show how you can now use the Windows version of avrasm2 to assemble the project.