Quick Reference:
-
If you have never used the W65C816SXB before, please work through the
W65C816SXB Getting Started Guide first.
-
Download 816EDU Getting Started Project (unzip into C:/wdc/W65C816SXB folder)
- *A special note about writing memory above BANK $0: The W65C816EDU is set up so that the 512KB memory exists from Bank $08 – Bank $0F. If you write anything to Bank $00 – Bank $07 or Bank $10 and above, the logic on the board will select Bank 0 and you will be writing to the SRAM (or FLASH depending on the address, although FLASH would not actually be written) on the W65C816SXB. Also, within the WDCDB debugger, there is an issue with displaying memory in any Bank other than Bank $00. It is recommended that if you need to use the debugger to view memory in Banks $08 – $0F, write a routine to copy the desired memory locations over to memory in Bank $00, where you can view and change memory within the debugger.
0.) W65C816SXB Getting Started Guide
If you have both the EDU and SXB boards but have never worked with the W65C816SXB, please work through the W65C816SXB Getting Started Guide before proceeding.
1.) Plug your W65C816EDU onto your W65C816SXB
The EDU board is an add-on board for the SXB, therefore it does not work by itself. Therefore we must connect the two first. The J1-J4 connectors on the EDU board are female sockets. These headers will fit directly onto the J1-J4 pin header connectors of the SXB board. Align each connector and gently press down. This is best done on a solid surface. Be careful with the PIA_PORTB connector as those pin headers are sharp. Alternating pressure at all 4 corners of the EDU will help it wiggle onto the SXB. You may find it easier to start the J4 ACIA connector and then work clockwise to the J2-PIA connector, etc. Be careful to make sure all of the pins are straight and nothing is bent during the process. Once you have a secure connection, you are ready to upload your first demo program. NOTE: once the EDU is secured it will be very difficult to remove.
2.) Example Program
If you did not download the Getting Started Example above, please do so from here. Extract/unzip the .ZIP file into the C:\WDC\W65C816SXB folder. Next, we will get started with the W65C816EDU using a simple program to work with the 8 LED and the buzzer on the EDU board. In addition, the 816EDU has a 512KB SRAM that can be utilized. The example program shows how to switch into Native mode in the W65C816S and access that memory. Then it switched back to Emulation mode. From there, the program functions very similarly to the W65C02EDU Getting Started program. Since the W65C816S starts up in Emulation mode, you can run programs made for the W65C02S directly.
The project files can be seen using Windows Explorer in the following folder: C:\WDC\W65C816SXB\EDU_GettingStarted\ASM\.
This project has a batch file that will assemble and link the project. It will also launch WDCDB Debugger.
Double-click on the mk816_EDUGS.bat file to execute the batch file.
Once the batch file runs, a windows Command window appears. It will stay on the screen until you close it. It should be the same as below if everything ran correctly.
Back in your Windows Explorer window, you will see several new files were created. These include the .OBJ (Object) file that is used by the linker to make the .BIN (WDC Binary) file. The debugger uses the BIN file to load the program into the memory of the W65C816SXB. A listing file (.LST) file is also created. You can view that file in any text editor and see both your code and the corresponding assembled addresses, opcodes, etc.
Another window that opens is the USB Options dialog box. This is very important for downloading programs into any WDC board using the WDCDB Debugger. If you do not have any other USB serial devices attached to your computer, you will only see one listing for your SXB board. Click on the name of the device, then click the Okay button.
The WDCDB Simulator/Debugger will launch. Below is a screenshot of the configuration of the Debugger for our program. This is just an example of how you can set up your windows. The “Status” windows let you know where data is loaded, etc. The “Registers” windows show the current values within each of the W65C816S microprocessor registers. The “File” window displays the code used for the program. It also highlights the line of code that is located at the current location of the microprocessors program counter (upon loading, the program will start at $2000). We have one “Data” window open showing data at $2000. The data at $2000 is the program that we wrote. If the file window is not showing like below, there may have been a communication issue with the board. Hit the RESB (RESB_PB) Pushbutton on the EDU board to restart the board and then rerun the batch file.
Now that the board has the program uploaded to it, we are ready to run the program. To do so, click on the Run menu, then click on Go. You can also hit the F9 function key on your keyboard. To stop the board while it is running, press the NMIB pushbutton, which is just to the right of the RESB pushbutton.
Here is a short video showing the LEDs changing quickly as the counter increments. This is an example of an 8-bit binary counter. The video is from the 02EDU, but you will see the same behavior on your board. The difference in the program is that the 512KB SRAM is written and read. Those values are copied to memory in Bank 0, which is in the SRAM of the W65C816SXB. Those values are read out and displayed on the LEDs. When the counter gets to 0xFF (all 8 bits are a 1), the counter will then reset to 0x00 on the next increment. When this happens, the example code sets the PIA CA2 signal HIGH to turn on the buzzer. After a short delay, CA2 is brought back LOW and the buzzer stops. Within the WDCDB debugger, you can step through the code (and over the delays) to see the LEDS change slower. You can also play with the code to add more delay loops or even make your own delay loop.
In the debugger, you can check the values of the memory written in $00:3000. Just click on View–>Data and type 3000 in the window that appears. When the Data Window appears, it should look similar to the one below.
This is just a simple example and you can explore the various pin functions and features of the W65C816S, W65C21, W65C22, and W65C51N chips as well as the onboard RTC, and any Grove, QWIIC, or MikroBUS modules that interest you.
*A special note about writing memory above BANK $0: The W65C816EDU is set up so that the 512KB memory exists from Bank $08 – Bank $0F. If you write anything to Bank $00 – Bank $07 or Bank $10 and above, the logic on the board will select Bank 0 and you will be writing to the SRAM (or FLASH depending on the address, although FLASH would not actually be written) on the W65C816SXB. Also, within the WDCDB debugger, there is an issue with displaying memory in any Bank other than Bank $00. It is recommended that if you need to use the debugger to view memory in Banks $08 – $0F, write a routine to copy the desired memory locations over to memory in Bank $00, where you can view and change memory within the debugger.