Jonathan Mordosky posts a loader in cosmacelf --------------------------------------------- I built my Membership Card a few weeks back and have been having a blast programming it. The 1802 has such an awesome architecture. I built it with 64K of ram with the idea that I could try different software without having to program and swap EPROMs. Accordingly, I wrote a BIN loader that I could toggle in to bring in base software. I figured I would post it here in case anyone else had a use for it. It's written for eight data bits, and no Parity at 300 Baud (what's your hurry, this is a hobby after all) but could probably do 1200 with no modifications. It's still a little long at 46 bytes and I'd welcome ideas to shorten it. I'm currently working on a small Monitor (< 1k) with XModem capability to go with it. Thank You Lee Hart for a great product! Jonathan later added: "A main goal for me in the design of the program, was to keep it as short as possible so that it is easier to toggle in, thus cutting out all the bells and whistles. Hopefully, the code is understandable enough that it will be possible to add any desired extra features on the fly as needed." Jonathan, Oct 24 2015 Lee Hart modifies the program ------------------------- Jonathan Mordosky published a great little serial loader for 1802 Elf/Membership card computers. I tried it, and it works! However, the timing is a little off, which limits it to low baud rates. I spent some some this evening to see if I could improve it. The attached file has Jonathan's program, and my enhancements. I haven't fully tested it, but thought [some of you] might like to see it. Analysis by Josh Bensadon ----------------------------- Very well done. I followed it through for the most part and I do believe it will work. I am going to try it on my VELF (I just need to change to EF2 and flip the polarity). Very nice and efficient use of the registers, and especially nice touch using long jump if DF for that extra 1/2 cycle needed. At first, I was concerned about the autobaud for 9600, since your resolution isn't very fine (increments of 2 cycles=3D 17.9 uSec) But, the loop will count to 2 in just 102.8uSec... Ahh, but wait... the testing of EF2 will happen within a 1 instruction cycle time, that's a 9uSec window! [From a timing drawing I made] there is a 1 in 8 chance that the EF signal will happen late enough to cause the counter to reach 3. I believe if you replace the NOP with just 2 more SEX 2's, you will push this error in favor of getting 2 every time for 9600 baud. [If not, says Lee, just assume 9600 and force it to 2 if you wish.] PS. For the purpose of mapping this out, I assumed the EF line is sampled on the 7th clock in the execute machine cycle, but it doesn't matter where it gets done, since it will just result in a sliding window anyway. [Lee added: It actually tests the EFn lines in the middle of the second clock pulse of the Execute cycle.] Now, I have entered the autobaud portion into my VELF and just output the Delay value then loop back. The VELF uses a 3.579+ MHz colour burst crystal [divided by 2 to run at about 1.79Mhz]. Here's the results of many times operation: Hitting at 9600, 100 times caused a delay of 2, 76 times and delay 3, 24 times. I then changed the NOP to another pair of SEX instructions and repeated the test. I got a delay of 2, 100 times out of 100. The display was so steady, I wondered if it was working, so I choose to test other bauds and got this: 4800: delay of 8 (steady) 2400: delay of 0x13 or 0x14 (about 50/50 but I'm not counting) 1200: delay of 0x2B (steady) 300: delay of 0xB6 (with the occasional 0xB7 about 10% of the time) To account for the high percentage of 3's (it was predicted 1/8th = 12.5%, not 24%). I will guess there must be a little lag in the RS-232, I mean to say some capacitance might be extending the pulse duration beyond 104.1666 uSec. Or the exact high/low voltage levels on the EF line may have an influence. Bottom line, I think Lee's program works great, it just needed a little more SEX. Lee Hart explains results -------------------------- [Josh is] right on needing 10 (not 9.5) instructions/loop. Theory is good, but practice makes perfect. I stared at it some more, and now see why. We don't want the *same* delay for baud rate detection and bit timing. Baud rate detection needs a "window" on each side of the desired number. At 1.8 MHz and 9600 baud, a bit is 11.65 instructions long. 11.5 instructions/bit is the closest the 1802 can get. The auto-baud routine therefore needs to check early, and late... at something like 11 and 12. But the loop that detects D5 has a 0 to 1 instruction delay, so the width of D5 appears to be 10.65-11.65 instruction times. Checking at 10 and 12 neatly "windows" the possible variations in apparent width of D5 so it always selects Delay=2. I modified my assembly listing accordingly, and attached a new version. Two other changes: I made the 1/2-bit delay 1 instruction shorter, by moving the STR 2 and GHI 3 to 0015-0016. When Delay=2, this makes it 3+Delay instructions from Start detect at 0017 to Bit test at 0020. I.e nominally 5 instructions at 9600 baud (where the actual time is something like 4.8-5.8 instruction times at 9600 baud). I could make it 5.5, but it would add bytes to this minimal loader and it may not be necessary. And Herb, I added an optional "test" patch at 0011-0013 to simply display the value of Delay. You can type repetitively and observe the values for any given baud rate. NOtes on application to the 1802 M/S card - Lee Hart ---------------------------------------- Early ones (rev.A-E) had an RC clock, adjusted with a trimpot. They'll work at lower baud rates, where clock speed variations with temperature and supply voltage won't matter. {Or, the owner can choose to add a ceramic resonator and resistor to run at full speed. - Herb] Later ones (rev.F-present) have a 1.8 MHz ceramic resonator (which actually tends to run at 1.79 MHz). - When the pot is set to high resistance (5k to 1meg), it runs at a low frequency set by the pot and 40pf capacitance of the resonator. - When the pot is set to zero, the clock runs as fast as the 4093 can go (about 2 MHz with a 5v supply). - When the pot is set for an RC frequency near 1.8 MHz (about 1-3k roughly 1/2 turn from the end), the resonator makes it "lock in" at 1.8 MHz. The frequency is very stable despite variations in temperature or supply voltage. Speculation on higher baud selection by Lee Hart ------------------------------------------- Actually, you might be able to send/receive at 19.2k, 28.8k, or even 38.4k baud! At 3.58MHz/2 = 1.79MHz, each 2-cycle instruction is 8.924uS. The number of instructions/bit needed for each of the standard higher baud rates is: baud instructions bus rate per bit cycles error ---- ------------ ------ ----- 9600 11.5 23 1.3% 19200 6 12 3% 28800 4 8 3% 38400 3 6 3% A 1.3% is obviously acceptable, and works. Using a 3-cycle instruction (an instruction and a half) gets us pretty close. A 3% error *might* still be close enough. If so... Leave out the Delay test (i.e a fixed baud rate routine). Here's the minimum loop I can think of, which is just 4 instructions: ; Enter with Start bit detected, and in the middle of Start bit, ; D=FF, and R(X) pointing to RAM where the bytes are to be stored NextBit BN3 Zero ;1 test next bit SKP ;2 if bit=1 (EF3 pin low), leave DF=1 Zero SHR ;2 if bit=0 (EF3 pin high), set DF=0 SHRC ;3 shift bit into byte (DF into D7, D0 into DF) BDF NextBit ;4 if DF=1, then Start bit hasn't shifted all ; the way thru byte. Loop until it does. ;This code should end in: STR 2 INC 2 ; (if X=2) or STR 2 OUT 4 ; to display the byte received on LEDs ; and then loop either way with STXD ; store byte in RAM, increment pointer, ; and loop back to find next byte 19200 needs a 6-instruction loop. So just add two 2-cycle do-nothing instructions to the loop. 28800 needs a 4-instruction loop. The above does that just as shown. 38400 needs 3 instructions per loop. We can't do that; but we *can* unwind the loop. Leave off the final BDF, and simply repeat the other 4 instructions nine times, once for Start and each of 8 data bit. I wonder if it would really work? :-) - Lee Notes on achieving a high baud rate - Herb Johnson -------------------------------------- But in the end...it's "I tried it and got to X baud rate". There's nothing wrong with a M/S card kit that only gets to 4800 baud, or 2400 baud. The point of the kit is to learn, have fun, get something working, to tinker around. The documentation on my site (searchable from Google search, Bing search, etc.) reflects years of versions of kits, each of which have their own particular "features". Learning about these features is informative; a kit that works perfectly without effort or puzzles provides no reasons to dig so deep. This document last updated Nov 2 2015 HRJ