The Western Design Center (WDC) has decided to write a series of tutorials on how to get started with our 65xx technology and how to write assembly language programs for the 65xx family of ICs. This tutorial will be based on using the W65C02 Standard chip Xxcelr8r Board (SXB) and utilizing a simple Hello World project.
The Hello World concept is to provide a simple program that when ran provides a way to connect with the world around you. In this example we will be manually blinking an LED light to represent our connection from the Software world to the physical world.
In this tutorial you will be running WDCTools on a Windows based system or emulated environment for IOS and connecting the W65C02SXB to a breadboard. We will be writing programs for the W65C02 Microprocessor connecting to the W65C22N VIA peripheral device. You should note that these same programs and techniques will work for the W65C816SXB.
The details of the W65C02SXB, Microprocessor and I/O Peripheral device can be found in the WDC data sheets so you may want to keep a copy of them for reference.There are also some download links for items you will need for this project.
W65C02SXB Data Sheet: http://www.westerndesigncenter.com/wdc/documentat...
W65C02S Data Sheet: http://www.westerndesigncenter.com/wdc/documentat...
W65C22N Data Sheet: http://www.westerndesigncenter.com/wdc/documentat...
WDCTools Download: http://wdc65xx.com/Products/WDCTools/
Notpade ++: https://notepad-plus-plus.org/
Here is what you will need:
1. A breadboard and two wires with a male and a female connection on either end. These parts are included in the BB400 XKit. Available at Mouser Electronics or Amazon
2. W65C02SXB (02SXB) Available at Mouser Electronics and Amazon
3. A computer running Windows 7,8, or 10
4. WDCTools Suite
5. A Text Editor- We like the free NotePad ++
5. Micro USB to USB Cable. (This is a standard cable that you probably use to charge your cell phone)
Step 1: Knowing Your W65C02SXB (Standard Chip Xxcelr8r Board)
Becoming familiar with what is layout and connectivity capability of your W65C02SXB is a good idea. This board is designed with the intention to work directly with all WDC 65xx IC family of chips. It not only provides a great platform for education but also a powerful engineering development platform. This means that as your understanding and capabilities grow this board will be all the board you need.
Download WDCTools and FTDI Driver at: http://wdc65xx.com/boards/02_816_SXB-engineering-d...
Here is a link to the WDC Getting started for the W65C02SXB: http://wdc65xx.com/gettingstarted/
Step 2: Getting Familiar With the W65C02S Microprocessor
The W65C02S is a low cost, general-purpose 8-bit microprocessor (8-bit registers and data bus) with a 16-bit program counter and address bus. The variable length instruction set and manually optimized core size are intended to make the W65C02S well suited for low power system-on-chip (SoC) designs.
Features of the W65C02S
- 8−bit data bus
- 16−bit Address Bus 65Kbyte Memory and IO Space
- 69 Variable Length Instructions
- 16 Addressing Modes
- 1.8−5V Operating Voltage
- Fully Static for Power and Radiation Management Verilog
This diagram shows the basic pin functions for the W65C02S.
The W65C02S also comes in several package types including:
- 40 Pin DIP
- 44 Pin PLCC (Used on the 02SXB and 816SXB)
- 44 Pin QFP
Step 3: Getting Familiar With the W65C22N and How It Is Connected to the W65C02SXB Header
Information about the W65C22:
The W65C22 (W65C22N and W65C22S) Versatile Interface Adapter (VIA) is a flexible I/O device for use with the 65xx series microprocessor family.
The W65C22 includes functions for programmed control of two peripheral ports (Ports A and B). Two program controlled 8-bit bidirectional peripheral I/O ports allow direct interfacing between the microprocessor and selected peripheral units. Each port has input data latching capability. Two programmable Data Direction Registers (A and B) allow selection of data direction (input or output) on an individual line basis.
Using this port for our project:
For this project we will be connecting from the VIA (J3) connector on your SXB board to a breadboard. The pin layout for this connector can be found in the illustration above.
- Pin 1 is identified with a square on this PAD and with a small dot on the edge of the board of the J3 connector.
- Pin layout information can be found in the W65C02SXB Data Sheet
Step 4: Setting Up Your Breadboard and Connecting It to the VIA Header
Setting up your Breadboard:
- Place an LED of your color choice to your breadboard so that the short leg is connected to the power row and the long leg is connected to a row on the board. I chose row 20 on my board.
NOTE: In this project you do not need to place a resistor to limit power to your LED because the W65C22N has a built in current limiting resistor.
Connecting to your SXB board:
- Pin two is directly behind pin one which is identified on the header with a small dot at the edge of the board. Pin 2 is identified as VSS or POWER.
- Connect the female end of your wire to the VSS location on the J3 connector
- Connect the male end of your wire to the Power row on your breadboard
- Then connect the female end of a new wire to pin 17 or PB0 on the J3 Header
- Connect the male end in line (left to right) with your LED. Given your board is connected to your computer and powered you should see your LED light up!
Step 5: Getting Ready for Assembly Language Programming
There are some key concepts that must be understood prior to learning to program a computer in assembly language. These concepts include the use of the binary and hexadecimal number systems, and how memory is addressed as bytes of data.
You can find helpful lessons regarding this at the WDC Xxcelr8r Academy in Lessons/Xplore Digital Technology: http://wdc65xx.com/thexxcelr8racademy/
This introduction will not address most of these things and will assume that you have some level of understanding and thus are wanting to become more acquainted with more recent 65xx technology and associated products such as the Xxcelr8r Board line.
Writing long strings of hexadecimal or binary instructions to program a computer is obviously not something you would want to do if you could at all avoid it. Assembly language, and programs which translate assembly language to machine code (called assemblers) were devised to simplify the task of machine programming.
Assembly language substitutes a short word – known as a mnemonic (which means memory aid) – for each binary machine code instruction. So while the machine code instruction 1010 1010, which instructs the 65x processor to transfer the contents of the A accumulator to the X index register, may be hard to remember, its assembler mnemonic TAX (for “Transfer A to X”) is much easier.
Writing in Assembly Language
In addition to understanding the processor you’re working with, you will also have a good knowledge of the particular assembler you are using to program in assembly language.
Most microcomputer assemblers have a great deal in common. They generally provide four columns, or fields, for different types of information about an operation: a label which can be used to symbolically identify the location of the code; the opcode; the operand; and space for comments.
While an opcode or directive appears in every assembler statement, the operand field may or may not be required by any particular opcode, since there are several one-byte instructions which consist solely of a opcode. The label and comment field are optional, added to make the program easier to read, write, debug, and modify later.
During assembly, the assembler checks the fields to be sure the information there is complete, of the proper type, and not out of order, and issues error messages to warn you of problems. It also checks to be sure you have not tried to define the same label twice, and that you have not used a label you did not define.
Note: WDCTools has a simulator as well so playing with a project is easy
Step 6: Programming Your Project
Ok now you must be ready to get this project started with your SXB board!
Below are a list of steps to get your projects working with your WDCTools. We have provided a basic program which is missing parts of the program such as memory location and your values for the accumulator. There are comments in the program which will help walk you through where these things need to be programmed but we left that all up to you.
- Plug your board into your PC
- Download the Hello World project from the WDC GitHub. You may need to sign up for a GitHub acount if you do not have one. Click this link: WDC GitHub Hello World project
- Save the Hello World project folder in your C drive under- C:/WDC/W65C02SXB/Projects. You will want to be sure that this project lives in your W65C02SXB projects folder so that when you open this project your path from your tools to your board is ready to go.
- Go to the Hello World Project folder and open the ASM file in your text editor. Here is where you will enter your program and save it. Once saved, it will always live in your projects folder location. So be sure that you make modifications and just hit save. This will make things pretty easy.
- Launch WDCTools TIDE interface
- Go to FILE and Open Project and go into your W65C02SXB Projects folder and select the Hello World file.
- Select your Hello World project and be sure that your file type is set to .WDC
- - You may need to adjust your the program screen to fit with the TIDE Tool box
- Click the Compile to Assembly button and check the program window at the bottom for errors
- Click the Assemble to Link button and check the program window at the bottom for errors
- Click the Debugger button. (Its the blue one with a Z in the middle of it)
- A window will pop up asking you to select your USB device location. Select location and click OKAY
- Your WDCDB window should launch and if your code window is blue you are ready to go!
- Push the F7 button to walk through your code if you did everything right then you should see your light blink On and Off.
Trouble Shoot if necessary.
Remember failure is a big part of Engineering. Improving your skills in trouble shooting problems is a big deal.