├── Images ├── 265SXB-proj-shield-aj01.jpg ├── 265SXB-uart0-usb.jpg ├── W65C256SXB_Memory_2.png ├── W65C256SXB_Memory_OOTB.png ├── W65C265SXB_J5_Header_Pins.png └── putty_setup_20161225.png ├── LICENSE ├── README.md ├── TODO.txt ├── entering_code.md ├── erratum.md ├── expansions.md ├── flash.md ├── links.md ├── memory.md ├── monitor.md ├── overview.md ├── serial_lines.md ├── setup.md ├── simple_programs.md ├── time.md └── wdc_tools.md /Images/265SXB-proj-shield-aj01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scotws/265SXB-Guide/1586006b0f58a45e3215c96ab9c23ba4476cd2d0/Images/265SXB-proj-shield-aj01.jpg -------------------------------------------------------------------------------- /Images/265SXB-uart0-usb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scotws/265SXB-Guide/1586006b0f58a45e3215c96ab9c23ba4476cd2d0/Images/265SXB-uart0-usb.jpg -------------------------------------------------------------------------------- /Images/W65C256SXB_Memory_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scotws/265SXB-Guide/1586006b0f58a45e3215c96ab9c23ba4476cd2d0/Images/W65C256SXB_Memory_2.png -------------------------------------------------------------------------------- /Images/W65C256SXB_Memory_OOTB.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scotws/265SXB-Guide/1586006b0f58a45e3215c96ab9c23ba4476cd2d0/Images/W65C256SXB_Memory_OOTB.png -------------------------------------------------------------------------------- /Images/W65C265SXB_J5_Header_Pins.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scotws/265SXB-Guide/1586006b0f58a45e3215c96ab9c23ba4476cd2d0/Images/W65C265SXB_J5_Header_Pins.png -------------------------------------------------------------------------------- /Images/putty_setup_20161225.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scotws/265SXB-Guide/1586006b0f58a45e3215c96ab9c23ba4476cd2d0/Images/putty_setup_20161225.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | CC0 1.0 Universal 2 | 3 | Statement of Purpose 4 | 5 | The laws of most jurisdictions throughout the world automatically confer 6 | exclusive Copyright and Related Rights (defined below) upon the creator and 7 | subsequent owner(s) (each and all, an "owner") of an original work of 8 | authorship and/or a database (each, a "Work"). 9 | 10 | Certain owners wish to permanently relinquish those rights to a Work for the 11 | purpose of contributing to a commons of creative, cultural and scientific 12 | works ("Commons") that the public can reliably and without fear of later 13 | claims of infringement build upon, modify, incorporate in other works, reuse 14 | and redistribute as freely as possible in any form whatsoever and for any 15 | purposes, including without limitation commercial purposes. These owners may 16 | contribute to the Commons to promote the ideal of a free culture and the 17 | further production of creative, cultural and scientific works, or to gain 18 | reputation or greater distribution for their Work in part through the use and 19 | efforts of others. 20 | 21 | For these and/or other purposes and motivations, and without any expectation 22 | of additional consideration or compensation, the person associating CC0 with a 23 | Work (the "Affirmer"), to the extent that he or she is an owner of Copyright 24 | and Related Rights in the Work, voluntarily elects to apply CC0 to the Work 25 | and publicly distribute the Work under its terms, with knowledge of his or her 26 | Copyright and Related Rights in the Work and the meaning and intended legal 27 | effect of CC0 on those rights. 28 | 29 | 1. Copyright and Related Rights. A Work made available under CC0 may be 30 | protected by copyright and related or neighboring rights ("Copyright and 31 | Related Rights"). Copyright and Related Rights include, but are not limited 32 | to, the following: 33 | 34 | i. the right to reproduce, adapt, distribute, perform, display, communicate, 35 | and translate a Work; 36 | 37 | ii. moral rights retained by the original author(s) and/or performer(s); 38 | 39 | iii. publicity and privacy rights pertaining to a person's image or likeness 40 | depicted in a Work; 41 | 42 | iv. rights protecting against unfair competition in regards to a Work, 43 | subject to the limitations in paragraph 4(a), below; 44 | 45 | v. rights protecting the extraction, dissemination, use and reuse of data in 46 | a Work; 47 | 48 | vi. database rights (such as those arising under Directive 96/9/EC of the 49 | European Parliament and of the Council of 11 March 1996 on the legal 50 | protection of databases, and under any national implementation thereof, 51 | including any amended or successor version of such directive); and 52 | 53 | vii. other similar, equivalent or corresponding rights throughout the world 54 | based on applicable law or treaty, and any national implementations thereof. 55 | 56 | 2. Waiver. To the greatest extent permitted by, but not in contravention of, 57 | applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and 58 | unconditionally waives, abandons, and surrenders all of Affirmer's Copyright 59 | and Related Rights and associated claims and causes of action, whether now 60 | known or unknown (including existing as well as future claims and causes of 61 | action), in the Work (i) in all territories worldwide, (ii) for the maximum 62 | duration provided by applicable law or treaty (including future time 63 | extensions), (iii) in any current or future medium and for any number of 64 | copies, and (iv) for any purpose whatsoever, including without limitation 65 | commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes 66 | the Waiver for the benefit of each member of the public at large and to the 67 | detriment of Affirmer's heirs and successors, fully intending that such Waiver 68 | shall not be subject to revocation, rescission, cancellation, termination, or 69 | any other legal or equitable action to disrupt the quiet enjoyment of the Work 70 | by the public as contemplated by Affirmer's express Statement of Purpose. 71 | 72 | 3. Public License Fallback. Should any part of the Waiver for any reason be 73 | judged legally invalid or ineffective under applicable law, then the Waiver 74 | shall be preserved to the maximum extent permitted taking into account 75 | Affirmer's express Statement of Purpose. In addition, to the extent the Waiver 76 | is so judged Affirmer hereby grants to each affected person a royalty-free, 77 | non transferable, non sublicensable, non exclusive, irrevocable and 78 | unconditional license to exercise Affirmer's Copyright and Related Rights in 79 | the Work (i) in all territories worldwide, (ii) for the maximum duration 80 | provided by applicable law or treaty (including future time extensions), (iii) 81 | in any current or future medium and for any number of copies, and (iv) for any 82 | purpose whatsoever, including without limitation commercial, advertising or 83 | promotional purposes (the "License"). The License shall be deemed effective as 84 | of the date CC0 was applied by Affirmer to the Work. Should any part of the 85 | License for any reason be judged legally invalid or ineffective under 86 | applicable law, such partial invalidity or ineffectiveness shall not 87 | invalidate the remainder of the License, and in such case Affirmer hereby 88 | affirms that he or she will not (i) exercise any of his or her remaining 89 | Copyright and Related Rights in the Work or (ii) assert any associated claims 90 | and causes of action with respect to the Work, in either case contrary to 91 | Affirmer's express Statement of Purpose. 92 | 93 | 4. Limitations and Disclaimers. 94 | 95 | a. No trademark or patent rights held by Affirmer are waived, abandoned, 96 | surrendered, licensed or otherwise affected by this document. 97 | 98 | b. Affirmer offers the Work as-is and makes no representations or warranties 99 | of any kind concerning the Work, express, implied, statutory or otherwise, 100 | including without limitation warranties of title, merchantability, fitness 101 | for a particular purpose, non infringement, or the absence of latent or 102 | other defects, accuracy, or the present or absence of errors, whether or not 103 | discoverable, all to the greatest extent permissible under applicable law. 104 | 105 | c. Affirmer disclaims responsibility for clearing rights of other persons 106 | that may apply to the Work or any use thereof, including without limitation 107 | any person's Copyright and Related Rights in the Work. Further, Affirmer 108 | disclaims responsibility for obtaining any necessary consents, permissions 109 | or other rights required for any use of the Work. 110 | 111 | d. Affirmer understands and acknowledges that Creative Commons is not a 112 | party to this document and has no duty or obligation with respect to this 113 | CC0 or use of the Work. 114 | 115 | For more information, please see 116 | 117 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # A Most Very Unofficial Guide to the W65C265SXB 2 | 3 | The W65C265SXB ("265SXB" for short) is an engineering development board produced 4 | -- basically a single-board computer in the same sense as the Raspberry Pi -- by 5 | the Western Design Center (WDC). It is based on the W65C265S microcontroler, 6 | which in turn has a 65816 MPU at its core -- the 8/16-bit hybrid "big sibling" 7 | of the famous 6502 MPU that powered classic computers such as the VIC-20 and 8 | Apple II. Because of the hybrid nature of the 65816, the 265SXB is pretty much 9 | the simplest way to get started with a 6502 system. 10 | 11 | This document is an unofficial guide to setting up, programming, expanding, and 12 | using the 265SXB. It supplements the official documentation provided by WDC. 13 | 14 | ## Index 15 | 16 | ### First Steps 17 | 18 | [Overview:](https://github.com/scotws/265SXB-Guide/blob/master/overview.md) 19 | What's in the box. 20 | [Setup:](https://github.com/scotws/265SXB-Guide/blob/master/setup.md) Getting 21 | the 265SXB up and running. 22 | [First 23 | Programs:](https://github.com/scotws/265SXB-Guide/blob/master/simple_programs.md) 24 | Simple things to do with the 265SXB right out of the box. 25 | [Uploading 26 | Programs:](https://github.com/scotws/265SXB-Guide/blob/master/entering_code.md) 27 | How to enter and/or upload programs to the 265SXB. 28 | 29 | ### Hardware 30 | 31 | [Memory:](https://github.com/scotws/265SXB-Guide/blob/master/memory.md) Out of 32 | the box configuration, how chip select signals are generated. 33 | [Flash:](https://github.com/scotws/265SXB-Guide/blob/master/flash.md) How to 34 | install, select a bank, and erase and program the flash memory chip under 35 | software control. 36 | [Serial 37 | Lines:](https://github.com/scotws/265SXB-Guide/blob/master/serial_lines.md) 38 | Connecting USB serial adapters to the serial lines of the 265SXB. 39 | 40 | ### Software 41 | 42 | [WDC Tools:](https://github.com/scotws/265SXB-Guide/blob/master/wdc_tools.md) 43 | Installing and working with the WDC development packages. 44 | [The Monitor:](https://github.com/scotws/265SXB-Guide/blob/master/monitor.md) 45 | Using the built-in Mensch Monitor program, a miniature operating system. 46 | [Clock and Timers:](https://github.com/scotws/265SXB-Guide/blob/master/time.md) 47 | Using the built-in clock functions. 48 | 49 | ### Projects and Expansions 50 | 51 | [Expansions:](https://github.com/scotws/265SXB-Guide/blob/master/expansions.md) 52 | Expansion boards, also known as "daughter boards" or shields. 53 | 54 | ### Appendix 55 | 56 | [Link list:](https://github.com/scotws/265SXB-Guide/blob/master/links.md) Useful 57 | links. 58 | [Erratum:](https://github.com/scotws/265SXB-Guide/blob/master/erratum.md) List 59 | of known errors in the Manual and bugs in the Mensch Monitor ROM listing. 60 | 61 | ## Thanks 62 | 63 | Various members of the [6502.org Forum](http://forum.6502.org/index.php) 64 | contributed to this document and gave invaluable advice. 65 | 66 | ## Disclaimer 67 | 68 | No liability for the contents of these documents can be accepted. Use the 69 | concepts, examples and information at your own risk. There may be errors and 70 | inaccuracies that could be damaging to your system. The author(s) take no 71 | responsibility for damage resulting. 72 | 73 | All copyrights are held by their by their respective owners, unless specifically 74 | noted otherwise. Use of a term in this document should not be regarded as 75 | affecting the validity of any trademark or service mark. Naming of particular 76 | products or brands should not be seen as endorsements. 77 | 78 | -------------------------------------------------------------------------------- /TODO.txt: -------------------------------------------------------------------------------- 1 | TODO List for the Inofficial W65C265SXB Guide 2 | 3 | (Do not link to this text from inside the guide) 4 | 5 | FIRST STEPS 6 | - Addition stuff to buy (Flash ROM chips, TTL-USB cable, rubber feet) 7 | 8 | SOFTWARE 9 | - Installing alternative monitors 10 | 11 | SERIAL LINES 12 | - How to set the baud rate 13 | 14 | SIMPLE PROJECTS 15 | - Adding two LEDs to show which of the ROM banks is being accessed 16 | - Breadboarding a single 512 RAM chip (see http://forum.6502.org/viewtopic.php?f=1&t=3552) 17 | - Breadboarding a single 512 Flash ROM chip 18 | 19 | ---- 20 | 21 | THINGS TO RESEARCH: 22 | - Bit banging SPI via serial ports? 23 | 24 | -------------------------------------------------------------------------------- /entering_code.md: -------------------------------------------------------------------------------- 1 | # Entering and Uploading Code to the W65S265SXB 2 | 3 | There various ways to get your own programs on the 265SXB. We assume here that 4 | you've written them on one of the various assemblers for the 65816 and have 5 | produced an assembled binary machine code file. 6 | 7 | As an example, we'll use the [PUT_STR 8 | code](https://github.com/scotws/265SXB-Guide/blob/master/monitor.md) from the 9 | chapter on the Mensch Monitor, which calls the Put String subroutine to print 10 | the string "Mensch" on the screen. The resulting code starts at 00:2000 and has 11 | the following hex dump: 12 | ``` 13 | 002000: 18 fb e2 20 c2 10 a9 00 a2 11 20 22 4e e0 00 00 14 | 002010: 00 4d 65 6e 73 63 68 00 15 | ``` 16 | The code size is 24 bytes. 17 | 18 | 19 | ## The hard way: Entering code by hand 20 | 21 | We have already seen the simplest, but also hardest way to enter code: Type it in 22 | through the Monitor by hand, as we did with our [first simple 23 | program](https://github.com/scotws/265SXB-Guide/blob/master/simple_programs.md). 24 | Once you have the Monitor started, press the "m" key, enter ```002000``` as the 25 | starting address, and type in the above sequence of bytes. To run the program, 26 | press the "j" key and enter ```002000``` as the start address. 27 | 28 | 29 | ## The less hard way: Sending S-Records 30 | 31 | This is doable for very, very short programs, but anything longer will quickly 32 | become error-prone and most tedious. Fortunately, the Monitor will accept 33 | programs sent to it in a special file format called SREC, the [Motorola 34 | S-record](https://en.wikipedia.org/wiki/SREC_(file_format)) format. Because of 35 | its 65816 MPU core with a 24-bit address space, we need "S28"-style formats. 36 | 37 | Converted to S28, our program would be an ASCII file (mensch.s28) with the 38 | following contents: 39 | ``` 40 | S0220000687474703A2F2F737265636F72642E736F75726365666F7267652E6E65742F1D 41 | S21C00200018FBE220C210A900A21120224EE00000004D656E73636800B2 42 | S5030001FB 43 | S804002000DB 44 | ``` 45 | 46 | We won't go into the format in greater detail, but note that the first to 47 | characters of each line are the "Record Field". We need S2 fields for the data 48 | because of 24 bit addresses, and in the last line S8 for the 24-bit terminating 49 | address. The first S0 line is the "header" and may look differently; in this 50 | case, it is the web page of the tool used to create the S28 file (see below). 51 | 52 | There are various ways to create and transmit S28 files. For instance, 53 | Andrew Jacobs' Java-based Assembler at 54 | [http://www.obelisk.me.uk/dev65/](http://www.obelisk.me.uk/dev65/) supports 55 | S-records, see 56 | [http://forum.6502.org/viewtopic.php?f=4&t=3551&p=42505#p42483](http://forum.6502.org/viewtopic.php?f=4&t=3551&p=42505#p42483) 57 | for a discussion on this topic. 58 | 59 | 60 | ### WDC Tools 61 | 62 | The WDC Tool package allows uploading of S28 records through the Debugger. As 63 | described 64 | [elsewhere](https://github.com/scotws/265SXB-Guide/blob/master/wdc_tools.md), 65 | the tools only run on Windows. 66 | 67 | 68 | ### Linux 69 | 70 | Creating and sending S-records with a Linux is a bit more complicated. First, we need the 71 | [srec_cat](http://srecord.sourceforge.net/man/man1/srec_examples.html) program 72 | to create the S28 files. On Ubuntu, run 73 | ``` 74 | sudo apt-get install srecord 75 | ``` 76 | To convert a binary file such as our mensch.bin, we need to provide an 77 | **offset** - where the program will be located in memory - and the **execution 78 | start address** for the correct format. In our case, these are the same 79 | addresses. Our complete srec_cat line is: 80 | ``` 81 | srec_cat mensch.bin -binary -offset 0x2000 -o mensch.s28 -address-length=3 -execution-start-address=0x2000 82 | ``` 83 | 84 | The options "-binary" tell srec_cat that we have a pure binary file, 85 | "-address-length=3" forces the S28 format for 24-bit addresses. To make sure we 86 | have the correct format, use ```srec_info mensch.s28``` to inspect the contents: 87 | ``` 88 | Format: Motorola S-Record 89 | Header: "http://srecord.sourceforge.net/" 90 | Execution Start Address: 00002000 91 | Data: 2000 - 2017 92 | ``` 93 | Note the useless Header field. 94 | 95 | Next, we can then use a program such as minicom to send the file as "plain 96 | ASCII" to the 265SXB. To do this, press the "s" key in the monitor. Then in 97 | minicom, type ```CONTROL-A Z``` for the main menu, then type "s" to send a file, 98 | using ASCII as a protocol. 99 | 100 | 101 | ## Further ways of entering code 102 | 103 | If you are Chuck Norris, the code will enter itself. 104 | 105 | -------------------------------------------------------------------------------- /erratum.md: -------------------------------------------------------------------------------- 1 | # Erratum for the W65C265SXB Manual and Mensch Monitor ROM listing 2 | 3 | This text includes known errors, typos, and bugs in the 4 | [Manual](http://www.westerndesigncenter.com/Wdc/documentation/265monrom.pdf) for 5 | the 265SXB and the [code 6 | listing](http://www.westerndesigncenter.com/wdc/documentation/265iromlist.pdf) 7 | of the Mensch Monitor ROM. 8 | 9 | ## The Manual 10 | 11 | (None registered so far) 12 | 13 | ## The Mensch Monitor ROM assembler code listing 14 | 15 | - page 4, line 179, in comment: bit 7 selects for banks $C0 to $FF, not "to CF" 16 | - page 109, lines 4970-4972, in code: CONTROL_TONES pushes Direct Page and Bank 17 | registers to the stack at the beginning of the routine, but does not pull them 18 | before exit (missing ```PLB``` and ```PLD``` instructions). 19 | 20 | 21 | -------------------------------------------------------------------------------- /expansions.md: -------------------------------------------------------------------------------- 1 | # Expanding the W65C265SXB 2 | 3 | The 50-pin Xbus265 on the left side of the board allows expanding the 265SXB 4 | with smaller plug-in boards, also known as "daughter boards", or "shields". 5 | 6 | ## Additional 1 MB of RAM 7 | 8 | This daughter board created by Andrew Jacobs uses two [AS6C4008 512K SRAM 9 | chips](http://www.alliancememory.com/pdf/as6c4008.pdf) and one [ATF16V8CZ-15PU 10 | PLD](http://www.mouser.com/ds/2/36/doc0453-35248.pdf) to add 1 MB of SRAM in the 11 | banks C0 to FF. 12 | 13 | ![AJ 1 MB expansion board](Images/265SXB-proj-shield-aj01.jpg) 14 | 15 | _Image: 1 MB expansion board, created by Andrew Jacobs._ 16 | -------------------------------------------------------------------------------- /flash.md: -------------------------------------------------------------------------------- 1 | # W65C265SXB Flash Memory 2 | 3 | The 265SXB comes with an unpopulated PLCC socket designed to hold a 128K flash 4 | memory chip (70ns or faster; U3 in upper right corner of the board). When 5 | installed, 32K of the flash memory is mapped into the address space between 6 | 00:8000 and 00:FFFF. How much is visible depends on whether the mask ROM 7 | (00:E000 - 00:FFFF) and peripheral registers/on-chip RAM (00:DF00 - 00:DFFF) are 8 | enabled. You can switch between the four 32K banks. Also, installing flash 9 | memory allows you to develop alternative ROM images that can execute 10 | automatically when the board is powered on. 11 | 12 | For these examples we will use the 13 | [SST39SF010A](http://ww1.microchip.com/downloads/en/DeviceDoc/25022A.pdf) flash 14 | memory chip. In the 265SXB, it is writeable under software control. Under normal 15 | operation the chip acts as a standard ROM but by writing an unlock sequence to 16 | specific offsets within the ROM the chip can be made to erase itself (entirely 17 | or in 4K sectors) and store new data. 18 | 19 | ## Selecting Banks 20 | 21 | The SST39SF010A provides 128K of memory, and comes with 17 address pins, A0 to 22 | A16. Since we only need 32K at any given time for the 265SXB, two of those pins 23 | are used to select which one of the four banks is active. The pins are 24 | controlled by the lines FA15 and FAMS on the 265SXB. FA15 is connected to 25 | address line 15 of the Flash memory, and FAMS to address line 16, which in flash 26 | memory chip documentation is called the "most significant address" (MS) of the 27 | memory chip - hence the names. 28 | 29 | Both pins are connected to port 4, which is controlled by a Data Direction 30 | Register (PDD4, 00:DF24) and the actual Data Register (PD4, 00:DF20). On reset, 31 | the PD4<4> and PD4<3> are configured as inputs and external resistors pull the 32 | FAMS and FA15 signals high. We can can take this to mean that we are accessing 33 | the fourth bank (binary "11", or bank 3) of the flash memory be default. To 34 | access the other banks (0 to 2), one or both of the pins should be reconfigured 35 | as a low output. 36 | 37 | The following routine is used in the W65C265 version of the SXB-Hacker to set 38 | the pins for a specific bank. 39 | 40 | ``` 41 | ; Select the flash ROM bank indicated by the two low order bits of A. The pins 42 | ; should be set to inputs when a hi bit is needed and a low output for a lo bit. 43 | 44 | public RomSelect 45 | RomSelect: 46 | php ; Save register sizes 47 | sep #1<<5 ; Then make A 8-bits 48 | longa off 49 | and #$03 ; Strip out bank number 50 | asl a ; And rotate into bits 51 | asl a 52 | asl a 53 | pha ; Save bit pattern 54 | eor #$18 ; Invert to get directions 55 | eor PDD4 ; Work out change 56 | and #$18 57 | eor PDD4 ; And apply to direction reg 58 | sta PDD4 59 | pla 60 | eor PD4 ; Then adjust data register 61 | and #$18 62 | eor PD4 63 | sta PD4 64 | plp ; Restore register sizes 65 | rts ; Done 66 | ``` 67 | 68 | ## Writing and Erasing Flash Memory 69 | 70 | The in-place write and erase operations of the SST39SF010A are controlled by 71 | command sequences that are sent to specific addresses with specific data. These 72 | sequences only use the 15 address lines A0 to A14, which allows us to specifiy 73 | that we want the high half of the 265SXB Bank 0 address through A15. 74 | 75 | > In the following code, we make this clear using the notation of 76 | > ```$8000+$5555``` and ```$8000+2aaa``` for the addresses $5555 and $2AAA 77 | > required. 78 | 79 | For the complete list of command sequences, see the [SST39SF010A 80 | documentation.](http://ww1.microchip.com/downloads/en/DeviceDoc/25022A.pdf) 81 | 82 | Whenever the flash chip is performing an internal operation, a read will 83 | return a value in which bit 7 is the inverse of the real value. During an erase, 84 | for instance, this means a read will return $7F until the erase is finished. 85 | 86 | ### Chip Erase 87 | 88 | The SST39SF010A provides a Chip-Erase operation, which allows the user 89 | to erase the entire memory array to the '1s' state. This is useful when the 90 | entire device must be quickly erased. 91 | 92 | The Chip-Erase operation is initiated by executing a six- byte Software Data 93 | Protection command sequence with Chip-Erase command ($10) with address $5555 94 | in the last byte sequence. 95 | 96 | ``` 97 | lda #$aa ; Unlock flash 98 | sta $8000+$5555 99 | lda #$55 100 | sta $8000+$2aaa 101 | 102 | lda #$80 ; Signal erase 103 | sta $8000+$5555 104 | lda #$aa 105 | sta $8000+$5555 106 | lda #$55 107 | sta $8000+$2aaa 108 | 109 | lda #$10 ; Chip erase 110 | sta $8000+$5555 111 | EraseWait: 112 | lda $8000 ; Wait for erase to finish 113 | cmp #$FF 114 | bne EraseWait 115 | ``` 116 | 117 | The chip erase operation takes around 70 mSec to complete. The controlling 118 | application should either perform a timed delay or poll the chip. 119 | 120 | ### Sector Erase 121 | 122 | The Sector-Erase operation allows the system to erase the device on a 123 | sector-by-sector basis. The sector architecture is based on uniform sector size 124 | of 4K bytes. 125 | 126 | The Sector-Erase operation is initiated by executing a six-byte command load 127 | sequence for Software Data Protection with then Sector-Erase command ($30) as 128 | the last byte. 129 | 130 | The flash chip uses the address that the command byte is written to to determine 131 | which 4K region of the chip is erased. 132 | 133 | The following code shows how to erase a block determined by an address between 134 | 00:8000 and 00:FFFF held in a zero page based pointer. The starting address of the 135 | 4K sector will be derived from the high order bits of the address (e.g. ADDR & 136 | $F000) plus the FAMS and FA15 signals. 137 | 138 | ``` 139 | lda #$aa ; Unlock flash 140 | sta $8000+$5555 141 | lda #$55 142 | sta $8000+$2aaa 143 | 144 | lda #$80 ; Signal erase 145 | sta $8000+$5555 146 | lda #$aa 147 | sta $8000+$5555 148 | lda #$55 149 | sta $8000+$2aaa 150 | 151 | lda #$30 ; Sector erase 152 | sta (ADDR) 153 | EraseWait: 154 | lda (ADDR) ; Wait for erase to finish 155 | cmp #$FF 156 | bne EraseWait 157 | ``` 158 | 159 | Erasing a sector takes around 18 mSec so further accesses to the flash memory 160 | must wait until the operation completes. 161 | 162 | ### Writing Bytes 163 | 164 | The flash chip can be programmed on a byte-by-byte basis. The write operation 165 | can only store '0' bits into the memory so the region to be programmed must be 166 | erased prior to writing. 167 | 168 | The programming application must perform three write operations to unlock the 169 | memory and initiate a byte write operation followed by a further write to 170 | store the actual data byte. 171 | 172 | The following code shows how to write a value held in a RAM location called 173 | DATA at an address in the 00:8000 to 00:FFFF range held in a zero page based 174 | pointer. 175 | 176 | ``` 177 | lda #$aa ; Yes, unlock flash 178 | sta $8000+$5555 179 | lda #$55 180 | sta $8000+$2aaa 181 | 182 | lda #$a0 ; Start byte write 183 | sta $8000+$5555 184 | 185 | lda DATA ; Write the value 186 | sta (ADDR) 187 | WriteWait: 188 | cmp (ADDR) ; Wait for write 189 | bne WriteWait 190 | ``` 191 | 192 | A write byte operation takes around 14 uSec. As with the erase operations 193 | you can perform read operation on the memory to find out when the write has 194 | been completed. 195 | 196 | 197 | ## Switching off the built-in 8K ROM 198 | 199 | On reset the BCR register (00:DF40) is set to $01 which enables the internal 200 | ROM. To disable it bit 7 of the BCR register must be set. For example: 201 | ``` 202 | LDA #$80 ; Disable Mensch ROM 203 | TSB BCR 204 | ``` 205 | The internal ROM uses interrupts so user code must disable interrupt 206 | generation, execute an SEI to ignore interrupts, or provide its own interrupt 207 | vectors until the internal ROM is renabled. 208 | ``` 209 | LDA #$80 ; Enable Mensch ROM 210 | TRB BCR 211 | ``` 212 | ![Memory Map](Images/W65C256SXB_Memory_2.png) 213 | 214 | _Image: Bank 00 showing the three simplest memory configurations. Light: RAM, 215 | dark: ROM, red: I/O registers and 64 byte on-chip RAM, grey: empty._ 216 | 217 | ## Autobooting ROM Images 218 | 219 | During the power on reset processing the Mensch Monitor checks the memory at 220 | 00:8000 for the string 'WDC'. If found the monitor jumps to address 00:8004 221 | handing control over to new firmware. 222 | 223 | When you are writing a ROM you should either use banks 0-2, which will be 224 | deselected when the reset button is pressed, or only change the detection string 225 | to 'WDC' when the code is thoroughly tested. 226 | 227 | If you are writing your own ROM with the WDC assembler then the ROM header 228 | is defined as follows: 229 | ``` 230 | section offset $8000 231 | 232 | db 'WDC',0 ; Only put WDC here when the ROM works 233 | reset: 234 | nop ; Execution starts here 235 | ``` 236 | In your ROM needs to use hardware interrupts or the memory area between 00:C000 237 | and 00:FFFF then it must disable the Mensch Monitor to reveal its own interrupt 238 | vector table at 00:FFE0. 239 | 240 | If you load a corrupt firmware image into bank 3 of the ROM then you may need to 241 | remove the flash chip and erase it in an external programmer. 242 | -------------------------------------------------------------------------------- /links.md: -------------------------------------------------------------------------------- 1 | # Useful links for the W65C265SXB 2 | 3 | ## General links 4 | 5 | http://6502.org/ Resource for all things related to 6502, 65816 and 65265 MPUs 6 | 7 | http://forum.6502.org/viewtopic.php?f=1&t=3552 General discussion about the 8 | 265SXB 9 | 10 | https://en.wikipedia.org/wiki/WDC_65816/65802 Wikipedia entry on the 65816 11 | 12 | 13 | ## WDC links and documentation 14 | 15 | http://wdc65xx.com/134_265_SXB-engineering-development-system/gettingstarted/ 16 | Official entry point for the 265SXB. Includes links to download tool set 17 | 18 | http://www.westerndesigncenter.com/wdc/documentation/w65c265sxb.pdf Official 19 | datasheet for the 265SXB development board 20 | 21 | http://www.westerndesigncenter.com/wdc/Schematics/W65C265SXB.pdf Official 22 | schematic for the 265SXB development board 23 | 24 | http://www.westerndesigncenter.com/wdc/documentation/w65c265s.pdf Official 25 | dataseet for the W65C265 microcomputer 26 | 27 | http://westerndesigncenter.com/wdc/documentation/w65c816s.pdf Official datasheet 28 | for the W65C816 CPU 29 | 30 | http://www.westerndesigncenter.com/Wdc/documentation/265monrom.pdf Mensch 31 | Monitor ROM Reference Manual 32 | 33 | http://www.westerndesigncenter.com/wdc/documentation/265iromlist.pdf Assembler 34 | code listing of the Mensch Monitor 35 | 36 | https://github.com/WesternDesignCenter GitHub page of WDC 37 | 38 | https://github.com/WesternDesignCenter/TerminalPython Simple terminal interface 39 | for the 265SXB written in Python 40 | 41 | http://www.alliancememory.com/pdf/sram/fa/as7c256av.1.2.pdf Datasheet for the 42 | AS7C256A-TIN 32k SRAM chip 43 | 44 | 45 | # User projects 46 | 47 | https://github.com/andrew-jacobs/w65c265sxb-hacker A tool for modifying the 48 | firmware on your WDC W65C265SXB Development Board 49 | 50 | https://github.com/Mortis69/EasySXB Terminal/program loader for SXB boards 51 | 52 | https://rodbiresch.wordpress.com/tag/w65c816/ Rod Biresch introduction to 65816 53 | on the 265SXB 54 | 55 | -------------------------------------------------------------------------------- /memory.md: -------------------------------------------------------------------------------- 1 | # The W65C265SXB Memory System 2 | 3 | The CPU at the heart of the 265SXB, the 65816, provides 24 address lines and can 4 | address up to 16 MB of memory. Internally, this space is segemented into 256 5 | "banks" of 64K each. When the CPU is emulating the 6502, only the first bank 6 | (first two hex digits are "00", also known as _Bank Zero),_ is accessed. See the 7 | 65816 Programming Manual for more details. 8 | 9 | If this sounds confusing, don't worry, the memory settings of the 265SXB are 10 | even worse. The easist way to understand them is to start with the "out of the 11 | box" configuration and then to work our way through the various settings to 12 | increase the address space. 13 | 14 | ## Out of the box 15 | 16 | The 265SXB is shipped with the following memory configuration: 17 | 18 | ![Memory Map] 19 | (https://github.com/scotws/265SXB-Guide/blob/master/Images/W65C256SXB_Memory_OOTB.png) 20 | 21 | _Image: Bank 00 showing the basic memory configuration. Light: RAM, 22 | dark: ROM, red: I/O registers and 64 byte on-chip RAM, grey: empty._ 23 | 24 | 25 | ### RAM 26 | 27 | The W65C265S microcomputer comes with 576 bytes of RAM on-chip: From 00:0000 to 28 | 00:01FF (512 bytes) and from 00:DF80 to 00:DFBF (64 bytes). The 265SXB also 29 | includes 32K of SRAM as an AS7C256A-10TIN (U2 on the upper left) enabled by 30 | default that span from 00:0000 to 00:7FFF. 31 | 32 | > Note: Technically, there is a difference if the 265SXB uses on-chip RAM for 33 | > 00:0000 to 00:01FF or the SRAM, but this is irrelevant for us at the moment. 34 | 35 | You can test if the 32K on-board SRAM is working by using the Monitor to modify 36 | the memory at, say, 00:7000 and then reading it back. 37 | 38 | ### ROM 39 | 40 | The 265SXB comes with 8K of burned-in on-chip ROM that holds the [Mensch 41 | Monitor](https://github.com/scotws/265SXB-Guide/blob/master/monitor.md), a 42 | simple operating system. This is located at 00:E000 to 00:FFFF and includes the 43 | various system vectors for interrupts. 44 | 45 | 46 | ### I/O and peripheral registers 47 | 48 | All non-CPU registers are found in the area from 00:DF00 to 00:DFFF together 49 | with 64 bytes of RAM as described above. 50 | 51 | 52 | ### How the Chip Select signals are generated 53 | 54 | Chip selection on the 265SXB is handled by lines that are attached to Port 7. In 55 | contrast to the other ports, it is output only. The Port 7 Chip Select Register 56 | (PCS7 at 00:DF27) determines how the individual lines of this port are used: A 57 | "0" bit (not set) turns that line into a normal output port of the associated 58 | data register (PD7 at 00:DF23). For example, if PCS7, bit 3 is "0", whatever is 59 | in PD7, bit 3 will be on the pin. However, a "1" bit (set) in PCS7 will enable 60 | that pin as a chip select line. 61 | 62 | The Data Sheet for the 265SXP gives a detailed table for the individual lines. 63 | Some of these are used internally. The ones that are interesting for us are: 64 | 65 | - **CS5B** selects the 4M address space in the banks $00 to $3F (pin 75). Note there 66 | are various "holes" punched in this space for the Flash ROM and other stuff at 67 | Bank 0. 68 | 69 | - **CS6B** selects the 8M address space in the banks $40 to $BF (pin 76). 70 | 71 | - **CS7B** selects the 4M address space in the banks $C0 to $FF (pin 77) 72 | 73 | These three signals are also exposed through the 50-pin XBus265 commector 74 | (connector J1). 75 | 76 | On hardware reset, the system first sets PCS7 to $00 and PD7 to $FF. However, 77 | during boot, the Mensch Monitor changes PCS7 to $FB and PD7 to $04 (see ROM 78 | listing at 00:E14B). 79 | 80 | (Why is bit 2 special? It controls the LED D1. Keeping this bit as "0" (not set) 81 | in PCS7 makes the associated line a normal output line, reflecting whatever is 82 | at bit 2 of PD7. By default, that is "1" (set), because the LED is triggered 83 | when low. In other words, the LED is off. In our section on [Simple 84 | Programs](https://github.com/scotws/265SXB-Guide/blob/master/simple_programs.md), 85 | we show how to turn it on.) 86 | 87 | In this configuration, the system uses the on-chip interrupt vectors, on-chip 88 | ROM, on-chip RAM, timer, control and other regiesters from 00:DF00 to 00:DFBF 89 | and 00:0000 to 00:01FF. 90 | 91 | ## Adding more memory 92 | 93 | The simplest way to add more memory is to install Flash memory in the 94 | unpopulated PLCC socket (U3 in upper right corner of the board); see the 95 | [chapter on flash 96 | memory](https://github.com/scotws/265SXB-Guide/blob/master/flash.md) for 97 | details. 98 | 99 | Beyond that, memory must be added with an external daughter board ("shield") 100 | attached to the 50 pin port. 101 | -------------------------------------------------------------------------------- /monitor.md: -------------------------------------------------------------------------------- 1 | # The W65C265SXB's built-in monitor program 2 | 3 | The 265SXB is shipped with a small built-in operating system, the Mensch Monitor 4 | (MM). As of time of writing (Jan 2016), the build shipped with the board was 5 | 2.0 from 1995. Yes, that made it more than 20 years old. 6 | 7 | The MM is "burned" into the board and cannot be removed, replaced, or 8 | overwritten. 9 | 10 | > Because of this, no backup of the MM is needed. 11 | 12 | However, you are able to jump from it to other ROM areas (if installed) and even 13 | mask it completely; see the chapter [on 14 | memory](https://github.com/scotws/265SXB-Guide/blob/master/memory.md) for 15 | details. 16 | 17 | 18 | ## The Manual 19 | 20 | The [Mensch Monitor 21 | Manual](http://www.westerndesigncenter.com/Wdc/documentation/265monrom.pdf), 22 | formally the *W65C265S Monitor ROM REFERENCE MANUAL* describes accessing and 23 | using the Monitor. At time of writing this document, the current version was 24 | Release 2.0 from February 10, 1995. 25 | 26 | > When working with the Manual, you should be aware that it is incomplete in 27 | > places and misleading in others. For example, it states that the PUT_CHR 28 | > routine will print the character to Port 3 -- in fact, it will happily 29 | > print the character out through the USB connection as we saw in the 30 | > first chapter in the example when we printed an "a" to the screen. You shold 31 | > therefore get used to consulting the source code listing. 32 | 33 | 34 | ## The Code Listing 35 | 36 | WDC also provides a [full 37 | listing](http://www.westerndesigncenter.com/wdc/documentation/265iromlist.pdf) Assembler 38 | code listing of the Mensch Monitor) of the Mensch Monitor which you will be 39 | referencing a lot. Note at the end there is a symbol table you can use to find 40 | where jump routines are located. 41 | 42 | 43 | ## Accessing the Built-In Routines 44 | 45 | The Mensch Monitor provides a whole number of subroutines that can be accessed 46 | from user programs. Note that most of these must be accessed through a long 47 | subroutine jump - for example, ```JSL 00E04B``` to print a character. They 48 | assume that the processor is in Native Mode, not Emulated as a 6502. 49 | 50 | ### Useful locations and variables 51 | 52 | **SIN_BUF2** Base location of input buffer for various input routines, initially 53 | set at 00:014D. Relevant code starts at 00:E2CF. 54 | 55 | **SINCNT2** Size of input buffer for various routines, initially set at 10 56 | characters (decimal). Relevant code starts at 00:E2BC. 57 | 58 | **SINEND2** Index for the last character removed from buffer. 59 | 60 | **SININDX2** Index for last character placed in buffer. 61 | 62 | 63 | ### Especially useful routines 64 | 65 | **GET_CHR** ("get character", 00:E036, main code at 00:FBF9) - Get a single 66 | character from the console, blocking until the character is received. Note this 67 | routine must be called with a long subroutine jump as ```JSL 00E036```. Returns 68 | with the carry bit clear and the character received in 8-bit A register. The 69 | character is not echoed, use GET_PUT_CHR for that. 70 | ``` 71 | ; GET_CHR example program. All numbers are hex. Assumes native mode 72 | 73 | .origin 2000 ; start at 00:2000 74 | .mpu 65816 ; tells assembler this is a 65816 MPU 75 | 76 | sep 20 ; switch A register to 8 bit 77 | rep 10 ; switch X register to 16 bit 78 | 79 | jsr.l 00:e036 ; JSL to GET_CHR 80 | 81 | brk 00 ; break to monitor, 00 is signature byte 82 | ``` 83 | Hexdump with 00:2000 as start location for testing with Mensch Monitor: 84 | ``` 85 | 002000: e2 20 c2 10 22 36 e0 00 00 00 86 | ``` 87 | > When you test this program with ```j 002000``` from the Mensch Monitor, it 88 | > will start waiting for the character immediately after the final 0 of the 89 | > address, because the Monitor command does not require a final ENTER. If you 90 | > do hit ENTER (common enough when first experimenting with the Mensch 91 | > Monitor), this will put $0D in the A register, the ASCII code for Carriage 92 | > Return (CR). 93 | 94 | If you are using GET_CHR to grab entries, note that things are not as simple as 95 | just getting one byte. ```Arrow Up```, ```Arrow Down```, ```ESC```, ```Page 96 | Up```, ```DEL```, and ```INS``` all return $1B with the carry bit clear. This is 97 | the [ASCII code for Escape](http://www.ascii-code.com/) that is followed by 98 | other ASCII characters for VT100 terminals for certain special characters. If 99 | you are going to use GET_CHR as a base for a command line input loop, you'll 100 | either have to include a timed loop to catch the other characters - see [this 101 | discussion](http://forum.6502.org/viewtopic.php?f=1&t=3552&p=49473#p49473) - or 102 | make due with the CONTROL combinations known from the [Bash shell keyboard 103 | shortcuts](http://www.howtogeek.com/howto/ubuntu/keyboard-shortcuts-for-bash-command-shell-for-ubuntu-debian-suse-redhat-linux-etc/): 104 | 105 | Input | GET_CHR code | ASCII of code | Bash function 106 | ------ | ------------ | ------------- | -------------- 107 | CTRL a | $01 | Start of Heading (SOH) | move cursor to start of line ("home") 108 | CTRL b | $02 | Start of Text (STX) | move cursor left 109 | CTRL c | $03 | End of Text (ETX) | abort current process 110 | CTRL d | $04 | End of Transmission (EOT) | exit current shell 111 | CTRL e | $05 | Enquiry (ENQ) | move cursor to end of line ("end") 112 | CTRL f | $06 | Acknowledgement (ACK) | move cursor right 113 | CTRL h | $08 | Back Space (BS) | rubout character ("backspace") 114 | CTRL l | $0c | Form Feed (FF) | clear screen 115 | CTRL n | $0e | Shift Out (SO) | next command ("down") 116 | CTRL p | $10 | Data Line Escape (DLE) | previous command ("up") 117 | CTRL z | $1a | Substitute (SUB) | suspend process 118 | 119 | These all return the carry bit clear. 120 | 121 | **GET_STR** ("get string", 00:E03F, main code at 00:F3D7) - Receives a string 122 | from the console until either ENTER or ESC is received and stores the string 123 | with a terminating 00 byte to a specified buffer. This routine must be called 124 | with a long subroutine jump as ```JSL 00E03F```. The address of the buffer must 125 | be provided by the bank byte in the 8-bit A register and the rest of the address 126 | in 16-bit X register. No arguments are returned. If the string entry was ended 127 | by an ENTER, the carry bit will be clear. If it was ended by an ESC, the carry 128 | bit will be set. Calls GET_PUT_CHR to echo the string. 129 | ``` 130 | ; GET_STR example program. All numbers are hex. Assumes native mode 131 | 132 | .origin 2000 ; starts at 00:2000 133 | .mpu 65816 ; tells assembler this is a 65816 MPU 134 | 135 | clc ; make sure we're in native mode 136 | xce 137 | sep 20 ; switch A register to 8 bit 138 | rep 10 ; switch X register to 16 bit 139 | 140 | lda.# 00 ; buffer bank is 00 141 | ldx.# 3000 ; buffer address is 3000 142 | jsr.l 00:e03f ; JSL to GET_STR 143 | 144 | brk 00 ; break to monitor, 00 is signature byte 145 | ``` 146 | Hexdump with 00:2000 as start location for testing with Mensch Monitor: 147 | ``` 148 | 002000: 18 fb e2 20 c2 10 a9 00 a2 00 30 22 3f e0 00 00 149 | 002010: 00 150 | ``` 151 | Note that if the string was terminated with ENTER, the last character in the 152 | string before the terminating 00 will be the ASCII character for Carriage Return 153 | (CR, $0D). In the above example, entering "Mensch Monitor" gives us 154 | ``` 155 | 003000: 4D 65 6E 73 63 68 20 4D 6F 6E 69 74 6F 72 0D 00 156 | ``` 157 | CONTROL-C will not abort the input, but will result in the ASCII character $03 158 | (end of text) being saved; a ENTER is still required to terminate the input. A 159 | single ESC will produce whitespace to the screen while testing in the Mensch 160 | Monitor and requires a second ESC to terminate. Terminating input with ESC will 161 | store everything up to, but not including, the ESC ASCII character in the 162 | buffer, will set the carry flag, and will store 00 in the A register. However, 163 | neither a carriage return (CR) nor the terminating zero are saved. 164 | 165 | **GET_BYTE_FROM_PC** ("get byte from input buffer", 00:E033, main code at 166 | 00:FBF9) - Returns a character from the input buffer. This routine must be 167 | called with a long subroutine jump as ```JSL 00E033```. If there is data in the 168 | buffer, it is returned with the carry bit clear and the data in the 8-bit 169 | accumulator. Otherwise, carry bit is set, and 8-bit accumulator contains 00 170 | (no data) or 80 (CONTROL-C or ESC received). This routine does not block, so 171 | testing it with the Mensch Monitor runs straight through, returning 00 in the A 172 | register and a set carry bit. 173 | 174 | **GET_PUT_CHR** ("get a character and echo to console", 00:E03C, main code at 175 | 00:F1C9) Gets a character from the input buffer and echos it back. This routine 176 | must be called with a long subroutine jump as ```JSL 00E03C```. Returns with the 177 | received character in 8-bit A register and the carry bit clear. 178 | ``` 179 | ; GET_PUT_CHR example program. All numbers are hex. Assumes native mode 180 | 181 | .origin 2000 ; start at 00:2000 182 | .mpu 65816 ; tells assembler this is a 65816 MPU 183 | 184 | clc ; make sure we're in native mode 185 | xce 186 | sep 20 ; switch A register to 8 bit 187 | rep 10 ; switch X register to 16 bit 188 | 189 | jsr.l 00:e03c ; JSL to GET_PUT_CHR 190 | 191 | brk 00 ; break to monitor, 00 is signature byte 192 | ``` 193 | Hexdump with 00:2000 as start location for testing with Mensch Monitor: 194 | ``` 195 | 002000: 18 fb e2 20 c2 10 22 3c e0 00 00 00 196 | ``` 197 | This routine blocks while waiting. Hitting ESC will return the equivalent ASCII 198 | character $1B with the carry bit clear during testing with Mensch Monitor (where 199 | two Escapes are required). 200 | 201 | **PUT_CHR** ("put character", 00:E04B, main code at 00:FDBC) - Output a single 202 | character to the console. Note that this routine must be called with a long 203 | subroutine jump as ```JSL 00E04B```. See [the example 204 | at](https://github.com/scotws/265SXB-Guide/blob/master/simple_programs.md) 205 | Simple Programs. Though the Manual states that the character is printed to port 206 | 3, it will actually work fine with the basic USB port. 207 | 208 | **PUT_STR** ("put string", 00:E04E; main code at 00:F3A1) - Output a string to 209 | the console. Must be called with long subroutine jump as ```JSL 00E04E```. Put 210 | the bank of the string address in the 8-bit A register, and the rest of the 211 | address in the 16-bit X register. The string must be terminated by a zero byte 212 | (00, ASCII "null"). This routine calls PUT_CHR. The routine does not add a 213 | carriage return and/or form feed. 214 | ``` 215 | ; PUT_STR example program. All numbers are hex 216 | .origin 2000 ; start at 00:2000 217 | .mpu 65816 ; tells assembler this is a 65816 MPU 218 | 219 | clc ; make sure this is native mode 220 | xce 221 | sep 20 ; switch A register to 8 bit 222 | rep 10 ; switch X register to 16 bit 223 | 224 | lda.# 00 ; load bank byte in A 225 | ldx.# teststr ; load 16-bit address in X 226 | jsr.l 00e04e ; JSL to PUT_STR 227 | 228 | brk 00 ; break to monitor; 00 is signature byte 229 | 230 | teststr 231 | .byte "Mensch",0 232 | .end 233 | ``` 234 | Hexdump with 00:2000 as start location for testing with Mensch Monitor: 235 | ``` 236 | 002000: 18 fb e2 20 c2 10 a9 00 a2 11 20 22 4e e0 00 00 237 | 002010: 00 4d 65 6e 73 63 68 00 238 | ``` 239 | The manual states the maximum string size is limited to 640 characters. No 240 | arguments are returned, no errors are reported, all registers are preserved. 241 | Though the Manual states that the character is printed to port 3, it will 242 | work fine with the basic USB port. 243 | 244 | **SEND_CR** ("send carriage return", 00:E066, main code at 00:F1D6) - Prints a 245 | Carriage Return (CR, $0D) to screen. Simply puts $0D in the A register and calls 246 | PUT_CHR. 247 | -------------------------------------------------------------------------------- /overview.md: -------------------------------------------------------------------------------- 1 | # Overview of the W65C265SXB 2 | 3 | The 4 | [W65C265SXB](http://wdc65xx.com/65xx-store/sxb-boards/w65c265sxb-engineering-development-system/) 5 | is a single board computer (SBC) - formally a "Engineering Development System" - 6 | created by WDC around the W65C265S 8/16-bit microcomputer. This in turn has the 7 | 65816 microprocessor at its core, the big sibling of the famous 8-bit 6502 8 | microprocessor that powered the Apple II, VIC-20, and others. 9 | 10 | > About those names: Note the number is "265", not "256" as you might assume, 11 | > which is a regular source of typos. "SXB" stands for "Standard chip 12 | > Xxcelr8r Board". Because the name is such a mouthful, we use "265SXB" as a 13 | > short form for the board in this document. 14 | 15 | The 265SXB [features:](http://65xx.com/boards/265-features/) 16 | 17 | - The W65C265S operating at 3.6864 MHz 18 | - 5V system powered via a Micro USB Connector 19 | - 32K of RAM on-board 20 | - 32PLCC socket for 128K of Flash ROM, mapped as upper 32K of memory 21 | - 50 "XBus265" connector with full data, access, and control lines for system 22 | expansion 23 | - 3 connector ports with 10 I/O pins each 24 | - Twin tone generator connector 25 | - Mensch Monitor 8K system monitor in ROM 26 | 27 | First access to the board is through a terminal interface via the USB connector, 28 | which makes the 265SXB one of the quickest paths to getting your hands on a 29 | running 6502/65816 system. 30 | 31 | -------------------------------------------------------------------------------- /serial_lines.md: -------------------------------------------------------------------------------- 1 | # Serial Lines on the W65C265SXB 2 | 3 | The 265SXB has four built-in UARTs for serial connections, numbered 0 to 3. The 4 | Mensch Monitor program uses UART3 with 9600 baud through the power jack in J6 at 5 | the bottom of the board for basic connections out of the box. Access to the 6 | other serial lines is through J5 on the bottom right of the board, where Ground 7 | (GND), 5V Power, and the four transmit (TXD)/receive (RXD) pairs are exposed. 8 | 9 | ## Hardware 10 | 11 | You will usually want to use a USB serial adapter such as a PL2303 12 | module. You will need to connect GND, TXD, and RXD to the correct pins of J5. 13 | 14 | ### J5 Header 15 | 16 | To find the correct pins, note that the *bottom right* pin of J5 is marked with 17 | a dot as pin 1 (5V). The one to the left of it is pin 2 (GND). 18 | 19 | ![J5 Header Pins] 20 | (https://github.com/scotws/265SXB-Guide/blob/master/Images/W65C265SXB_J5_Header_Pins.png) 21 | 22 | To connect the USB serial adapter, connect ground to ground and the TXDs to 23 | RXDs. 24 | 25 | ![USB serial adapter] 26 | (https://github.com/scotws/265SXB-Guide/blob/master/Images/265SXB-uart0-usb.jpg) 27 | 28 | _Image: USB serial adapter connected to UART0 through pins 3 and 4 with ground 29 | on pin 2. 265SXC with [1 MB 30 | Shield](https://github.com/scotws/265SXB-Guide/blob/master/expansions.md). Note 31 | the dot next to pin 1 on the header._ 32 | 33 | Put differently, the the TXD pins are on the left, the RXD pins on the right. 34 | 35 | ### Registers 36 | 37 | The four UARTs each have a data register (formal name: _asynchronous 38 | receiver/transmitter register,_ ARTDx) and a _status/control_ register 39 | _(asynchronous status/control register,_ ACSRx). They are located at the 40 | following memory addresses: 41 | 42 | | UART (x) | Data Reg (ARTDx) | Stat/Cont Reg (ACSRx) | 43 | | :------: | :--------------: | :-------------------: | 44 | | 0 | 00:DF71 | 00:DF70 | 45 | | 1 | 00:DF73 | 00:DF72 | 46 | | 2 | 00:DF75 | 00:DF74 | 47 | | 3 | 00:DF77 | 00:DF76 | 48 | 49 | The control/status registers have the following bits: 50 | 51 | | Bit | Function | 52 | | :-: | :----------------- | 53 | | 0 | Xmit port enable | 54 | | 1 | Xmit IRQ source | 55 | | 2 | 7/8 bit data | 56 | | 3 | Parity enable | 57 | | 4 | Odd/even parity | 58 | | 5 | Receive enable | 59 | | 6 | Software semiphore | 60 | | 7 | Receive error flag | 61 | 62 | In the Mensch Monitor, the serial parts are initialized starting at 00:FE71, and 63 | the Baud Rate is set up starting 00:FE21. 64 | 65 | -------------------------------------------------------------------------------- /setup.md: -------------------------------------------------------------------------------- 1 | # Setting up the 265SXB 2 | 3 | Getting the 265SXB up and running requires the board itself, a USB cable, and a 4 | host computer. The board draws power via the USB connection, which is also used 5 | for the terminal. This gives you access to the built-in monitor program. 6 | 7 | > Note: Various documents online suggest you need a second, USB-to-TTL cable 8 | > attached to the UART port J5 at the bottom right to access the terminal. This 9 | > is incorrect. 10 | 11 | ## Connecting a Linux machine 12 | 13 | As an example, we connect the 265SXB to a Ubuntu Linux machine via a USB port. 14 | 15 | 1. Attach the USB cable to the board at J6, the power jack in the bottom middle. 16 | Attach the other end to your computer. This should make the power LED light up. 17 | Feel free to cackle and whisper "It's alive!" 18 | 19 | 2. On the Ubuntu machine, we will use `putty` as a terminal program. If not 20 | already present, install it with `sudo apt-get install putty` from a shell. To 21 | start the terminal program, you might need to type `sudo putty`. 22 | 23 | 3. To find out which USB port on the host computer we are using, run `dmesg | 24 | grep tty` from the shell. In our case, the port is `/dev/ttyUSB0`: 25 | ``` 26 | scot@core:~ dmesg | grep tty 27 | [ 0.000000] console [tty0] enabled 28 | [ 0.655088] 00:06: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 29 | 16550A 30 | [ 8791.523313] usb 3-6: FTDI USB Serial Device converter now attached to ttyUSB0 31 | ``` 32 | 33 | 4. Configure putty: Under the Terminal setting, enable "implicit LF in every 34 | CR". Under the Session setting, select "Serial" and use the port address found 35 | in the previous set as the Serial Line. Click "Open" at the bottom of the window 36 | to create the connection. 37 | 38 | ![Putty Setup] 39 | (https://github.com/scotws/265SXB-Guide/blob/master/Images/putty_setup_20161225.png 40 | "Putty Setup") 41 | 42 | 5. On the 265SXB, push the Reset button to the right of the power jack J6. 43 | 44 | This should bring up the Mensch Monitor, a very basic form of an operating 45 | system. See the chapter on [The 46 | Monitor](https://github.com/scotws/265SXB-Guide/blob/master/monitor.md) for more 47 | detail. 48 | 49 | Instead of putty, the command-line program `minicom` can be used, which can do 50 | useful stuff like upload S28-records. 51 | 52 | 1. Install with `sudo apt-get install minicom`. 53 | 54 | 2. After finding the USB port of the 265SXB as above, start minicom with `sudo 55 | minicom -s`. 56 | 57 | 3. Configure the serial device as `/dev/ttyUSB0` and the Bps speed as `9600`. 58 | Under the entry "Screen and keyboard", enable the adding of line feeds and 59 | carriage returns. Save the configuration as "265sxb". 60 | 61 | 4. After configuration, you can call the 265sxb with `sudo minicom 265sxb`. 62 | 63 | See 64 | [Ubuntu minicom help](https://help.ubuntu.com/community/Minicom) for details. 65 | 66 | -------------------------------------------------------------------------------- /simple_programs.md: -------------------------------------------------------------------------------- 1 | # Simple First Programs for the W65C265SXB 2 | 3 | Now that the 265SXB is set up and running, we'll prove that it's alive with a 4 | few very simple programs. 5 | 6 | ### How to enter code the hard way 7 | 8 | For these examples, we'll be entering the machine code byte-by-byte through the 9 | console and the Mensch Monitor routines, the most primitive way to program the 10 | 265SXB. In later chapters, we'll show more efficient, but also more complicated 11 | ways to add code. 12 | 13 | 14 | ## Printing a single character 15 | 16 | In this first example, we're going to print the letter "a" on the screen. Get 17 | the 265SXB started and the Mensch Monitor running. Now, press the "m" key and 18 | enter the address ```002000```. The Monitor will print a string of hex digits 19 | and then prompt you to add the new values. Type the following sequence (without 20 | spaces, which the Monitor will take care of for you): 21 | ``` 22 | a9 61 22 4b e0 00 00 23 | ``` 24 | Hit ENTER when you are done. Now, press the "j" key and type ```002000```, the 25 | address of the little program you just entered. Immediately after typing the 26 | last "0", a small "a" will appear after it and the Monitor will print out the 27 | register contents and other status information. The whole sequence should look 28 | something like this (look for the little "a" right behind the address 29 | ```00:2000``` right about in the middle): 30 | ``` 31 | >m 32 | BB:AAAA 00:2000 33 | Address 0 1 2 3 4 5 6 7 8 9 A B C D E F 34 | 35 | 00:2000 F7 FD BD 93 B4 B4 BE 20 DB BE 1A 3D C7 DC B1 A0 36 | 00:2000 a9 61 22 4b e0 00 00 37 | 38 | READY 39 | >j 40 | Enter Address BB:AAAA 00:2000a 41 | 42 | PCntr Acc Xreg Yreg Stack 43 | 00:2008 00 61 E0 B7 00 FE 01 FC 44 | 45 | DirRg F DBk 46 | 00 00 20 00 47 | 48 | 49 | Status Reg 50 | N V M X D I Z C 51 | 0 0 1 0 0 0 0 0 52 | 53 | > 54 | ``` 55 | The little program we entered by hand in machine language looks like this in 56 | assembler: 57 | ``` 58 | Standard Assembler: Typist's Assembler: 59 | 60 | LDA #$61 lda.# 61 61 | JSL 00E04B jsr.l 00:e04b 62 | BRK brk 63 | ``` 64 | What we are doing here is using the Mensch Monitor's built-in PUT_CHR routine 65 | to print the character in the Accumulator to the screen. More about using the 66 | built-in routines in the [Monitor chapter] 67 | (https://github.com/scotws/265SXB-Guide/blob/master/monitor.md). 68 | 69 | ## Making a LED blink 70 | 71 | _This section was inspired by Rod Biresch's blog post [Blink the LED "Hello 72 | World!"](https://rodbiresch.wordpress.com/2015/06/30/blink-the-led-hello-world/)_ 73 | 74 | Printing a single character shows us how to play around with the software of the 75 | 265SXB. Now we'll do something very simple with the hardware: Blink an LED. 76 | 77 | In our section on [Memory 78 | Configuration](https://github.com/scotws/265SXB-Guide/blob/master/memory.md), we 79 | take a closer look at how chip select signals are generated by lines attached to 80 | the output-only Port 7. One of these lines services the D1 LED at P72 (see [the 81 | 265SXB 82 | Schematic](http://www.westerndesigncenter.com/wdc/Schematics/W65C265SXB.pdf)). 83 | We can make it blink with two small routines: 84 | 85 | ``` 86 | Standard Assembler: Typist's Assembler: 87 | 88 | LDA #$00 lda.# 00 89 | STA $DF23 sta 00:df23 90 | BRK brk 91 | LDA #$04 lda.# 04 92 | STA $DF23 sta 00:df23 93 | BRK brk 94 | ``` 95 | Assembled, this gives us the machine code: 96 | ``` 97 | A9 00 8D 23 DF 00 A9 04 8D 23 DF 00 98 | ``` 99 | As above, use the Mensch Monitor to store this sequence at 00:2000. To turn the 100 | LED on, type ```j``` followed by ```002000```; to turn it back off, jump 101 | to 00:2006. 102 | 103 | (Note there are other LEDs on the board, but they are tied to the chip select 104 | lines for the RAM and Flash memory.) 105 | -------------------------------------------------------------------------------- /time.md: -------------------------------------------------------------------------------- 1 | # Time, Date and Timers on the W65C265SXB 2 | 3 | The 265SXB comes with eight programmable timers, numbered TO to T7. Of these, 4 | only T7 is only really freely available to the user. 5 | 6 | ## Timers 7 | 8 | | Timer | Name | Function | At boot | Clock | 9 | | --- | :--- | :--- | --- | --- | 10 | | T0 | Watchdog | Breaks infinite loops | off | (TBA) | 11 | | T1 | General purpose | Interrupts for time-of-day clock | on | CLK | 12 | | T2 | (TBA) | Can provide regular interrupts | (TBA) | FCLK/16 | 13 | | T3 | Baud rate generator | Services UARTs | on | (TBA) | 14 | | T4 | Baud rate generator | Serivces UARTs | on | FCLK or P60 | 15 | | T5 | Tone generator | Telephone applications | (TBA) | FCLK | 16 | | T6 | Tone generator | Telephone applications | (TBA) | FCLK | 17 | | T7 | (TBA) | Can provide interrupts | off | FCLK | 18 | 19 | T4 can count pulses on P60/TIN if not used as a baud rate generator, and 20 | provide square wave reference on P61/TOUT. 21 | 22 | T7 can generate timer interrupts via TIFR or used for pulse width measurement 23 | (PWM). 24 | 25 | 26 | ## Time-of-Day Clock 27 | 28 | The time-of-day clock (TOD) is updated in one-second intervals by software. 29 | There is no RTC chip on the 265SXB. In low-power mode (invoked, for example, 30 | by pressing "x" in the Mensch Monitor), the date and time are not lost, but 31 | they are also _not_ updated. 32 | 33 | ### Mensch Monitor use 34 | 35 | The clock starts up immediately on boot with "12:00:00" as the "current" time. 36 | To see the time and change it, type "t". The Mensch Monitor will prompt you to 37 | type in a new time. Hitting ENTER will keep the old time. 38 | 39 | The "current" date is "07-01-93" (note to non-American users: This format is 40 | "Month-Day-Year"). To see the date and change it, type "n". As with the time, 41 | the Monitor will prompt you to change it by typing a similiar string. 42 | 43 | -------------------------------------------------------------------------------- /wdc_tools.md: -------------------------------------------------------------------------------- 1 | # The WDC Tools for the W65C265SXB 2 | 3 | The 265SXB comes with a set of tools provided by WDC at 4 | [http://wdc65xx.com/Products/WDCTools/](http://wdc65xx.com/Products/WDCTools/). 5 | To download them, enter your name and e-mail address at the website and you will 6 | receive an email with a download link for the zip file. 7 | 8 | > The tools are closed-source proprietary software that will only run on 9 | > Windows, not Linux or Mac OS. 10 | 11 | The *.exe file contains an installer program that will set up the packages. 12 | 13 | --------------------------------------------------------------------------------