banedon wrote:
While I wait for my 65C02 GPD project to be fabricated, I'm looking at making my first 65C816 project.
Congratulations. You will be entering a new realm of 65xx computing, where things actually get easier.
Quote:
I intend the following:
- Run the MPU in native mode
- Utilise the full memory map of 16MB
- Possibly split the project into two PCBs (due to size)
- Employ 2 VIA chips - 1 for system I/O (keyboard and LCD, settings ROM, RTC) and 1 general I/O
- Employ 1 ACIA for serial I/O
Given that the 65C51 in its present form has a significant hardware bug, perhaps you should consider a non-65xx UART. My recommendation is the NXP 28L92, but there are others whose performance is commensurate with the capabilities of the 65C816. The 28L92 is dual channel, but it never hurts to have some spare I/O capability. Tested, interrupt-driven '816 native mode code exists for driving that UART.
In your "shopping list," you mention using a VIA timer as the RTC. If you elect to use the 28L92 UART you will get with it a precision timer whose rate is not slaved to Ø2, unlike the timers in the VIA. POC V1.1's timekeeping is driven by the 28L92's counter/timer, and has proved to be quite stable. Again, tested '816 native mode code for that exists.
Quote:
From what I can discover, I need to use a '573 latch which is enabled to transfer the data bus to A16-A23 on PHI2 going low. Possibly use an inverter on the clock to enable the /LE pin with /OE always held low.
I presume you have referred to the circuit shown on page 46 of the 65C816 data sheet. You can use it as shown, except you can skip the '245 transceiver (there are better ways to prevent data bus contention during Ø2 low), and eliminate the Ø2 inverter to /LE by instead generating a two phase clock, viz:
Attachment:
File comment: Two-Phase Clock Generator
clock_gen_2p.gif [ 53.85 KiB | Viewed 1678 times ]
You would connect /LE on the '573 to the PHI1 output in the above clock generator circuit; PHI2 would drive the MPU and your VIAs.
Speaking of the '573, it has to be fast so as to latch A16-A23 early enough during Ø2 low to produce a comfortable timing margin for RAM selection. This is where a 74ABT573 would be recommended if you plan to take Ø2 up to the maximum (data sheet attached). Slightly slower but still quite fast is the 74AC573. I would not recommend the 74HC573 in this application for anything above 8 MHz.
Quote:
I'll start off using a GAL for glue logic, but this might not have enough pins...not sure. When I can afford it, I'm going to use a CPLD instead.
This looks like a job for a 22V10. Even so, you will have to plan carefully.
Quote:
Assumptions & Unknowns
I believe that the MPU starts off in emulation mode and requires some commands to enable native mode (hence the lack of reset vector in native mode)
Correct. Emulation mode is entered at power-on or when the reset pin is pulled low.
Quote:
Not sure how to set the stack address and how to limit its size, although I do know that it can only reside in bank 0 (000000-00FFFF)
Here is some example code to get you thinking:
Code:
;================================================================================
;
;hrst: HARD SYSTEM RESET
;
hrst sei ;no IRQs during 1st stage POST
cld ;ensure binary mode
sec ;select emulation mode to...
xce ;default DB, DP & PB &...
clc ;register widths
xce ;return to & stay in native mode
...
rep #%00110000 ;16 bit registers
lda #hwstack ;top of hardware stack ($00CDFF)
tcs ;initialize stack pointer
;
The above is from POC V1.1's firmware.
The
SEC -- XCE sequence puts the '816 into emulation mode, which defaults the data and program banks, forces the stack pointer to
$FF and puts all registers into 8 bit mode. The
CLC -- XCE sequence puts the '816 into native mode and makes the stack pointer a 16 bit register, but still loaded with
$00FF. Once in native mode, POC stays there. Later on, the stack pointer is set to
$CDFF (defined by
HWSTACK). Following the setting of the stack pointer you would initialize your I/O and continue system boot.
As for limiting the size of the stack, that is not something that can be programmatically accomplished unless you write code that checks the stack pointer each time a stack operation is to be performed (very slow). Since the stack grows downward until the stack pointer wraps to
$FFFF, you simply have to accept the fact that improper stack management could result in a collision with code or data at some point.
In POC's firmware, I placed the top of the stack below the four TIA-232 FIFOs (128 bytes each) so stack growth couldn't impinge on them. All of the bank
$00 RAM from
$000150 upward is for code and data, which means that unchecked stack growth will eventually step on something. It has not happened due to being careful in writing programs that make heavy use of the stack.
I recommend that you place the top of the stack very high in RAM as I did and leave the address space from
$000000 upward as contiguous space for code and data. That way, stack growth is less likely to step on other things in memory. Unlike the 65C02, whose zero and stack pages are fixed, you can relocate direct page and give each function an ephemeral direct page if needed. So you are much less constrained in that regard. I set the "base" direct page location in POC to
$000000 and as mentioned above, the top of stack to
$00CDFF. The TIA-232 FIFOs extend from
$00CE00 to
$00CFFF, and the I/O block starts at
$00D000. So I have contiguous bank
$00 RAM from
$000000 to
$00CFFF, a total of 52K.
Quote:
Possible Memory Map
Bank 0
$0000-$00FF [RAM] Direct page (Zero page)
$0100-$03FF [RAM] Stack (this may change)
$0400-$7FFF [RAM] OS working RAM
$8000-$80FF [Air gap] (nothing mapped)
$8100-$81FF [VIA #1, System], 16 bytes used
$8200-$82FF [VIA #2, General I/O], 16 bytes used
$8300-$83FF [ACIA], 4 bytes used
$8400-$8FFF [Air gap]
$9000-$FFFF [ROM/BIOS]
The ROM mapping is awkward, in my opinion, as it isn't an even multiple of the usual ROM sizes. Any ROM you use is likely to be 8K, 16K or 32K. Assuming the top of the BIOS ROM is at
$00FFFF, then the start of ROM would be
$00E000,
$00C000 or
$008000, respectively. Starting at
$009000 will demand the use of more product terms in the GAL, but without accomplishing much of value.
16K of ROM is more than enough to hold a complete BIOS, plus a copy of Supermon 816. I stuffed all of that into 8K of ROM in POC V1.1.
In general, you should consider bank
$00 address space to be valuable real estate, since it has to be occupied by direct page, the MPU stack, enough ROM to hold reset and interrupt routines, and (for programming efficiency) I/O devices and their data structures. Hence a goal in your design should be to efficiently utilize the bank
$00 space and make as much of it available for RAM as practicable. Avoiding "air gaps" is one way to accomplish that. Limiting ROM size to what is necessary is another.
Attachment:
File comment: 74ABT573 Octal Transparent D-Latch
74abt573_latch.pdf [1.13 MiB]
Downloaded 103 times