Hello there!
While discussing UniDOS implementation with OffseT he asked me if it would be possible to add some non-volatile RAM to the CPC. This works like RAM, but the content is not erased when the computer is off. The idea is to store UniDOS configuration there. Currently it is stored in the Albireo SD card, but this isn't convenient if you don't have an Albireo.
We then also talked about other problems, such as the need for extra RAM for UniDOS to work with non-Albireo devices where a filesystem is needed on the z80 side (with Albireo that is not needed, the hardware implements the filesystem and exposes high level file access commands).
So I researched how to do this and came up with this interface. It includes 8K or 32K of NVRAM (depending on which chip you use) and a real-time-clock (because NVRAM chips have that, and, why not?).
Schematics:
http://pulkomandy.tk/drop/nova_cpc_nvram.pdfSome technical details:
The interface uses port FE82 for mapping the NVRAM in and out. It is possible to map it at any multiple of &2000.
The high 4 bits determine the base address.
For example:
OUT &FE82,&0x ' to map at 0000-1FFF
OUT &FE82,&2x ' to map at 2000-3FFF
...
OUT &FE82,&Ex ' to map at E000-FFFF
The NVRAM, when it is enabled, masks 8K of RAM or ROM and replaces it with its own contents.
The low 4 bits determine what is mapped:
OUT &FE82,x8 ' map the first 8K page
OUT &FE82,x9 ' map the second 8K page
OUT &FE82,xA ' map the third 8K page
OUT &FE82,xB ' map the fourth 8K page
For the 8K version, only page 4 is available.
Any other value for the 4 low bits unmaps the NVRAM and restores the normal RAM or ROM behavior.
In the fourth page, the last 8 bytes are not normal RAM, but can be used to read and write the time from the realtime clock. So your CPC can know which day and time it is. In the other pages (if available) there is only RAM.
Access to the RTC works this way (assuming the interface is mapped at 6000-7FFF):
POKE &7FF8,&40
year = PEEK(&7FFF)
month = PEEK(&7FFE)
day = PEEK(&7FFD)
weekday = PEEK(&7FFC)
hour = PEEK(&7FFB)
minute = PEEK(&7FFA)
second = PEEK(&7FF9)
POKE &7FF8,&00
All values are in BCD format (4 bits for tenths, 4 bits for units)
To set the time:
POKE &7FF8,&80
POKE &7FFF,&21 ' for 2021
POKE &7FFE,&02 ' february
' ... and so on ...
POKE &7FF8,&00
Any comments? Suggestions? Questions? Did I make some mistakes in the schematics?