%DASHBOARD{ section="dashboard_start" }% %DASHBOARD{ section="banner" image="%PUBURLPATH%/Cosmac/RaspiElf/raspi-elfmemcard-s.jpg" title="Forth for the Membership Card" titlestyle="color:#F00000;" }% %DASHBOARD{ section="box_start" title="Intro" width="485" height="200"}% <cite> Computers are machines just like the marionette. They must be told exactly what to do, in specific language. And so we need a language which possesses two seemingly opposite traits: On the one hand, it must be precise in its meaning to the computer, conveying all the information that the computer needs to know to perform the operation. On the other hand, it must be simple and easy-to-use by the programmer. </cite> From chapter "Introduction for Beginners", Leo Brodie, Starting FORTH https://www.forth.com/starting-forth/ %DASHBOARD{ section="box_end" }% %DASHBOARD{ section="box_start" title="Contents" width="460" height="200"}% %TOC% %DASHBOARD{ section="box_end" }% %DASHBOARD{ section="box_start" width="992" height="600" title="Rc/Forth and IDIOT Monitor for RaspiElf (Membership Card)"}% ---+ Rc/Forth and IDIOT Monitor for RaspiElf (Membership Card) Mark Abene made FORTH work on the Membership Card. $ forth.hex: Modified version of Mike Riley's Rc/Forth, ROM version. Changed to work with my modified version of IDIOT. Loads in at 0500h. You can get it from the [[https://groups.yahoo.com/neo/groups/cosmacelf/files/Mark%20Abene/forth.hex][COSMAC ELF yahoo group]]. $ idiot_new.hex: New version of IDIOT with SCRT routines, along with TYPE, MSG, READ, and INPUT routines for basic console I/O. Loads in at 0000h. You can get it from the [[https://groups.yahoo.com/neo/groups/cosmacelf/files/Mark%20Abene/idiot_new.hex][COSMAC ELF yahoo group]]. For details see http://www.retrotechnology.com/memship/mship_idiot.html Concatenated this two files as mc-forth.hex and convert it to a binary file: <pre> pi@cosmac:~/elf/forth $ <b>cat idiot_new_qhi.hex forth.hex > mc-forth.hex</b> pi@cosmac:~/elf/forth $ <b>hex2bin mc-forth.hex</b> hex2bin v2.5, Copyright (C) 2017 Jacques Pelletier & contributors Allocate_Memory_and_Rewind: Lowest address: 00000000 Highest address: 00001633 Starting address: 00000000 Max Length: 5684 Binary file start = 00000000 Records start = 00000000 Highest address = 00001633 Pad Byte = FF pi@cosmac:~/elf/forth $ <b>ls -l</b> insgesamt 40 -rw-r--r-- 1 pi pi 12132 Jan 13 12:36 forth.hex -rw-r--r-- 1 pi pi 2890 Jan 13 12:36 idiot_new.hex -rw-r--r-- 1 pi pi 5684 Jan 13 12:41 mc-forth.bin -rw-r--r-- 1 pi pi 15022 Jan 13 12:36 mc-forth.hex </pre> Now upload and start Rc/Forth (mc-forth.bin): <pre> pi@cosmac:~/elf/forth $ <b>bin2elf -w -r mc-forth.bin</b> 0x1634 bytes written </pre> clear high (8th) bit of input characters <pre> pi@cosmac:~/elf/forth $ <b>stty -F /dev/ttyS0 istrip</b> </pre> and start the terminal emulator (console): <pre> pi@cosmac:~/elf/forth $ <b>microcom -s 600</b> connected to /dev/ttyS0 Escape character: Ctrl-\ Type the escape character followed by c to get to the menu or q to quit <b><i>[CR]</i></b> IDIOT/4 *<b>$P500</b> Rc/Forth 0.1 (c) copyright 2006 by Michael H. Riley ok <b>15 5 + .</b> 20 ok <b>BYE</b> IDIOT/4 * </pre> %DASHBOARD{ section="box_end" }% %DASHBOARD{ section="box_start" width="992" height="600" title="Rc/Forth and Chuck's Super Monitor for RaspiElf (Membership Card)" }% ---+ Rc/Forth and Chuck's Super Monitor for RaspiElf (Membership Card) Mark Abene made Rc/Forth also work with Chuck's Super Monitor. I prefer this monitor because of its ability to communicate with 9600 baud. $ mcsmp_rcforth.hex: Mike Riley's Rc/Forth, modified to work with Chuck Yakym's MCSMP20 firmware. You can get it from the [[https://groups.yahoo.com/neo/groups/cosmacelf/files/Mark%20Abene/mcsmp_rcforth.hex][COSMAC ELF yahoo group]]. $ !MCSMP20B.bin: Chuck's Super monitor. Loads in at 0000h. You can get it from the [[http://www.sunrise-ev.com/MembershipCard/MCSMP20B.bin][Lee A. Hart's website The COSMAC ELF Membership Card ]]. Create binary file and load it at 0x8000: <pre> pi@cosmac:~/elf/forth $ <b>hex2bin mcsmp_rcforth.hex</b> hex2bin v2.5, Copyright (C) 2017 Jacques Pelletier & contributors Allocate_Memory_and_Rewind: Lowest address: 00008000 Highest address: 000091DB Starting address: 00008000 Max Length: 4572 Binary file start = 00008000 Records start = 00008000 Highest address = 000091DB Pad Byte = FF pi@cosmac:~/elf/forth $ <b>bin2elf -s 8000 mcsmp_rcforth.bin</b> 0x11dc bytes written </pre> Now upload and start the monitor, start the terminal program with 9600 baud: <pre> pi@cosmac:~/elf/forth $ <b>bin2elf -w -r MCSMP20B.bin</b> 0x8000 bytes written pi@cosmac:~/elf/forth $ <b>microcom -s 9600</b> connected to /dev/ttyS0 Escape character: Ctrl-\ Type the escape character followed by c to get to the menu or q to quit <b><i>[CR]</i></b> Membership Card's Serial Monitor Program Ver. 2.0B Enter "H" for Help. ><b>R8000</b> Currently running your program Rc/Forth 0.1 (c) copyright 2006 by Michael H. Riley ok </pre> %DASHBOARD{ section="box_end" }% %DASHBOARD{ section="box_start" width="992" height="450" title="Night Rider in Rc/Forth" }% ---+ Night Rider in Rc/Forth See ChaseLighting for an assembler version (much faster of course). Here a small test program for the Rc/Forth. It's a simple night rider chase lighting, but it is using the MC LEDs (of course), the switches for setting the pace and the IN button to terminate the program. Some interactive programming to find out how OUT is working: <pre> ok 1 4 OUT ok 4 1 OUT ok 4 2 OUT ok : LED! 4 SWAP OUT ; ok 4 LED! </pre> The rest of the program, every word can and should be tested interactively (e.g. 1 LEFT): <pre> : SWITCH@ 4 INP ; : DELAY 1 SWITCH@ + 0 DO LOOP ; : LEFT 7 0 DO 2 * DUP LED! DELAY LOOP ; : RIGHT 7 0 DO 2 / DUP LED! DELAY LOOP ; : NIGHTRIDER 1 DUP LED! BEGIN LEFT RIGHT EF 8 <> UNTIL DROP ; </pre> Push the IN button to terminate the program. %DASHBOARD{ section="box_end" }% %DASHBOARD{ section="box_start" width="992" height="600" title="Mass storage" }% ---+ Mass storage Forth without mass storage (blocks, screens) is a not complete. A SD-Card interface could be a reasonable solution but this is an overkill for a small Forth system. ---++ EEPROM Serial Communication Serial Peripheral Interface SPI, MC is the SPI master, the host is the slave. e.g. [[http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-8832C-SEEPROM-AT25M02-Datasheet.pdf][AT25M02]] SPI EEPROM 2Mbit (256 !KiB, $3), [[http://ww1.microchip.com/downloads/en/DeviceDoc/20005265A.pdf][25LC1024]] (128 !KiB, $2), or [[http://ww1.microchip.com/downloads/en/DeviceDoc/20005265A.pdf][25LC512]] (64 !KiB, $1.50). DIL8 Package. 64/128/256 !KiB seems very small for today's standards where storage is quantified in !GiB, but I think it's more than enough for a small Forth system. If you want more memory there is 16 !MiB serial EEPROM [[http://www.winbond.com/resource-files/w25q128jv%20spi%20revc%2011162016.pdf][W25Q128J]] from WINBOND, please note that is a 3.3 V part! <verbatim> CLK MC ->- host MOSI MC ->- host MISO MC -<- host SS MC ->- host or other peripherals (optional) </verbatim> A high-to-low transition on the _CS_ pin is required to start an operation and a low-to-high transition is required to end an operation. _Invalid Opcode_: If an invalid opcode is received, no data will be shifted into AT25M02 and the Serial Data Output (SO) pin will remain in a high impedance state until the falling edge of CS is detected again. This will reinitialize the serial communication. While in _Hold_ mode, the SO pin will be in a high impedance state. In addition, both the SI pin and the SCK pin will be ignored. !25LCxxxx Instruction Set | *Name* | *Format* | *Description* | | _READ_ | 0000 0011 | Read data from memory array beginning at selected address | | _WRITE_ | 0000 0010 | Write data to memory array beginning at selected address | | _WREN_ | 0000 0110 | Set the write enable latch (enable write operations) | | _WRDI_ | 0000 0100 | Reset the write enable latch (disable write operations) | | _RDSR_ | 0000 0101 | Read STATUS register | | _WRSR_ | 0000 0001 | Write STATUS register | | PE | 0100 0010 | Page Erase erase one page in memory array | | SE | 1101 1000 | Sector Erase erase one sector in memory array | | CE | 1100 0111 | Chip Erase erase all sectors in memory array | | RDID | 1010 1011 | Release from Deep power-down and read electronic signature | | DPD | 1011 1001 | Deep Power-Dow | !AT25M02 Instruction Set | *Name* | *Format* | *Description* | | _READ_ | 0000 0011 | Read from Memory Array | | _WRITE_ | 0000 0010 | Write to Memory Array | | _WREN_ | 0000 0110 | Set Write Enable Latch (WEL) | | _WRDI_ | 0000 0100 | Reset Write Enable Latch (WEL) | | _RDSR_ | 0000 0101 | Read Status Register (SR) | | _WRSR_ | 0000 0001 | Write Status Register (SR) | | LPWP | 0000 1000 | Low Power Write Poll | ---+++ Serial EEPROM Connected to Centronics Connector (Switches and LEDs) Sharing the LED and Switch port, you loose two LEDs and one switch. Possible conflict with the bootstrap loader, if there is a read sequence (CS and read pattern 0000 0011). To prevent this, set the EEPROM into HOLD state e.g. with the <SPAN STYLE="text-decoration:overline">WAIT</SPAN> signal. | *SPI* | *MC (Master)* | *25LCxxxx (Slave)* | *Interface* | | MISO | J2.1 <SPAN STYLE="text-decoration:overline">IN</SPAN> EF4 | 2 SO | diode e.g. 1N4148 | | MOSI | J2.11 O7 LED7 | 5 SI | direct | | CLK | J2.10 O6 LED6 | 6 SCK | direct | | CS | J2.12 O5 LED5 | 1 <SPAN STYLE="text-decoration:overline">CS</SPAN> | direct | | | P4.3 VDD | 8 VCC | +5V capacitor 100 nF to GND | | | " | 3 <SPAN STYLE="text-decoration:overline">WP</SPAN> | +5V | | | J2.14 <SPAN STYLE="text-decoration:overline">WAIT</SPAN> | 7 <SPAN STYLE="text-decoration:overline">HOLD</SPAN> | direct | | | 21 GND | 4 GND | GND | %IMAGE{"%PUBURLPATH%/Cosmac/McForth/mc-eeprom-conn.png" type="thumb" caption="Schematic"}% Raspberry Pi can emulate SPI EEPROM. On RaspiElf the switches/LEDs are already connected to Raspi's GPIOs. No need for additional hardware. But I have to write an SPI server for the Raspberry Pi. Raspi's SPI interfaces can't be used because of conflicting port usage. * BCM 19 (SPI1 MISO) O5 * BCM 20 (SPI1 MOSI) - * BCM 21 (SPI1 SCLK) shutdown * BCM 18 (SPI1 CS0) <SPAN STYLE="text-decoration:overline">CLR</SPAN> * BCM 17 (SPI1 CS1) <SPAN STYLE="text-decoration:overline">WAIT</SPAN> * BCM 9 (SPI0 MISO) IN4 * BCM 10 (SPI0 MOSI) IN3 * BCM 11 (SPI0 SCLK) IN6 * BCM 8 (SPI0 CS0) IN7 * BCM 7 (SPI0 CS1) O0 ---++++ Read Byte <pre> CS0 EQU 0b1101111 CS1 EQU 0b0010000 CLK0 EQU 0b1011111 CLK1 EQU 0b0100000 DATA0 EQU 0b0111111 DATA1 EQU 0b1000000 ; MSB first READBYTE: LDI 0 PLO R5 LDI 0xFF PHI R6 LDI 0xFF - 8 PLO R6 SEX R0 BITLOOP: OUT4,0b01000000 ; CLK for SPI OUT4,0b00000000 INC R6 GHI R6 ; set CARRY SHRC GLO R5 B4 SETBIT ; branch if bit set SHL ; bit not set BR SAVEBIT SETBIT: SHLC SAVEBIT: PLO R5 GLO R6 BNZ BITLOOP </pre> about 230 cycles for one byte -> 1 ms -> 1 KiB takes about 1 s @ 1.79 MHz ---++++ Write Byte <pre> WRITEBYTE: LDI 0 PHI R6 LDI 8 PLO R6 SEX R0 BITLOOP: GLO R5 ; get the next bit SHLC , next bit is in the carry PLO R5 BDF SETBIT OUT4,0b01000000 ; CLK for SPI with data bit cleared OUT4,0b00000000 BR NEXT SETBIT: OUT4,0b11000000 ; CLK for SPI with data bit set OUT4,0b10000000 NEXT: DEC R6 GLO R6 BNZ BITLOOP </pre> ---+++ Serial EEPROM patched on MC PCB SPI Mode 0, data is always latched in on the rising edge of SCK and always output on the falling edge of SCK. For CS one output port bis is needed e.g. O7 or N2 (INP4) to start/end operation (A high-to-low transition on the _CS_ pin is required to start an operation and a low-to-high transition is required to end an operation). | *SPI* | *MC (Master)* | *25LCxxxx (Slave)* | *Interface* | | MISO | <SPAN STYLE="text-decoration:overline">EF2</SPAN> | 2 SO | direct | | MOSI | D0 | 5 SI | direct | | CLK | TPB & N1 (OUT2) | 6 SCK | [[https://en.wikipedia.org/wiki/Wired_logic_connection][wired AND]]; Pullup 10 k, 2 1N4148 | | CS | N2 | 1 <SPAN STYLE="text-decoration:overline">CS</SPAN> | direct | | | | 8 VCC | +5V | | | | 3 <SPAN STYLE="text-decoration:overline">WP</SPAN> | +5V | | | J2.14 <SPAN STYLE="text-decoration:overline">WAIT</SPAN> | 7 <SPAN STYLE="text-decoration:overline">HOLD</SPAN> | direct | | | | 4 GND | GND | ---++++ Read Byte <pre> ; MSB first LDI 0 PLO R5 LDI 0xFF PHI R6 LDI 0xFF - 8 PLO R6 SEX R6 BITLOOP: OUT2 ; CLK for SPI, INC Rx GHI R6 ; set CARRY SHRC GLO R5 B2 SETBIT ; branch if bit set SHR ; bit not set BR SAVEBIT SETBIT: SHRC SAVEBIT: PLO R5 GLO R6 BNZ BITLOOP </pre> about 200 cycles for one byte -> 1 ms -> 1 KiB takes about 1 s ---++++ Write Byte <pre> WRITEBYTE: LDI 0 PHI R6 LDI 8 PLO R6 SEX R0 BITLOOP: GLO R5 ; get the next bit SHLC , next bit is in the carry PLO R5 LSNF OUT2,0b00000000 ; CLK for SPI with data bit cleared LSDF OUT2,0b00000001 ; CLK for SPI with data bit set DEC R6 GLO R6 BNZ BITLOOP </pre> ---++ Kermit/ZModem What about using KERMIT or ZMODEM protocol for the file transfer and use the file system on the host? No need to add additional hardware (SD-card is anyway to modern ;-) You could use an old CP/M or even a PDP11 as host. The C-Kermit Local Server mode, e.g. MC can read/write the blocks as files =block.0=, =block.2=, =block.255=. The serial communication is really slow, not only because of the 9600 baud, but you have to wait after each character to give CDP1802 some computation time. https://github.com/utoh/pygmy-forth/blob/master/extras/kermit/pfkerm.doc %DASHBOARD{ section="box_end" }% %DASHBOARD{ section="box_start" width="992" height="400" title="Spare Time Gizmos ELF2K ROM for RaspiElf" }% ---+ Spare Time Gizmos ELF2K ROM for RaspiElf For details see Herb Johnson's [[http://www.retrotechnology.com/memship/elf2k_mship.html][ELF 2K ROM for 1802 Membership Card]] [[http://www.sparetimegizmos.com/Downloads/v88.hex][v88.hex]] from the [[http://www.sparetimegizmos.com/Hardware/Elf2K.htm][Spare Time Gizmos]] web site. <pre> pi@cosmac:~/elf/elf2k $ <b>cp v88.hex v88.hex.org</b> pi@cosmac:~/elf/elf2k $ <b>patch v88.hex v88-mc.patch</b> pi@cosmac:~/elf/elf2k $ <b>hex2bin v88.hex</b> hex2bin v2.5, Copyright (C) 2017 Jacques Pelletier & contributors Allocate_Memory_and_Rewind: Lowest address: 00000000 Highest address: 00007FFF Starting address: 00000000 Max Length: 32768 Binary file start = 00000000 Records start = 00000000 Highest address = 00007FFF Pad Byte = FF pi@cosmac:~/elf/elf2k $ <b>bin2elf -s 8000 v88.bin</b> 0x8000 bytes written pi@cosmac:~/elf/elf2k $ <b>bin2elf -w -r LBR_8000.bin</b> 0x0003 bytes written pi@cosmac:~/elf/elf2k $ </pre> But there is "Post Code 97" -> EPROM checksum wrong %DASHBOARD{ section="box_end" }% %DASHBOARD{ section="dashboard_end" }% -- %USERSIG{PeterSchmid - 2019-01-13}% ---++!! Comments
Attachments
Attachments
Topic attachments
I
Attachment
History
Action
Size
Date
Who
Comment
png
mc-eeprom-conn.png
r3
r2
r1
manage
20.4 K
2019-01-19 - 23:12
PeterSchmid
patch
v88-mc.patch
r1
manage
1.1 K
2019-01-20 - 10:36
PeterSchmid
This topic: Cosmac
>
WebHome
>
McForth
Topic revision: r18 - 2019-01-20 - PeterSchmid
Copyright © 2008-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback