Home » RBC Forums » General Discussion » Newbie with Tiny68K (Description of a newbie's experiences with Tiny68K)
Newbie with Tiny68K [message #4150] |
Fri, 26 January 2018 08:57  |
smp
Messages: 49 Registered: January 2018 Location: Bedford, NH, USA
|
Member |
|
|
Hello all,
I'm new here - I recently purchased a Tiny68K board from Bill Shen, and while I was waiting to be admitted here onto the Forum, I've been e-mailing with Bill. I'd like to make a few posts to recount my experiences for the benefit of others.
My board arrived safe & sound, and came up right away. I'm having difficulty with the USB-to-TTL converter trying to get CTS & RTS working. The cables I already had were all only 3-wire connections, with no CTS & RTS. Those all have worked fine for the terminal interface with CTS & RTS jumper together. Next, I tried one from eBay, but it only worked for the TX & RX, but not for CTS & RTS. I see that I screwed up and got a 3.3V version, so I am hopeful that my next try from Amazon will work. That one should arrive today. I'll give it a try and report back.
Thanks for listening!
smp
|
|
|
Re: Newbie with Tiny68K [message #4151 is a reply to message #4150] |
Fri, 26 January 2018 08:58   |
smp
Messages: 49 Registered: January 2018 Location: Bedford, NH, USA
|
Member |
|
|
Now that I've posted my first message, hopefully my links will now work...
I'm having difficulty with the USB-to-TTL converter trying to get CTS & RTS working. The cables I already had were all only 3-wire connections, with no CTS & RTS. Those all have worked fine for the terminal interface with CTS & RTS jumper together. Next, I tried this, from eBay:
https://www.ebay.com/itm/FTDI-FT232RL-USB-Cable-to-Serial-ad aptmodule-USB-TO-TTL-RS232-Arduino-Cable-PR/302571041695?ssP ageName=STRK%3AMEBIDX%3AIT&_trksid=p2060353.m2749.l2649
Again, this works for the TX & RX, but not for CTS & RTS. I see that I screwed up and got a 3.3V version, so I am hopeful that my next try will work:
https://www.amazon.com/gp/product/B010KII6VG/ref=oh_aui_deta ilpage_o00_s00?ie=UTF8&psc=1
This unit should arrive today. I'll give it a try and report back.
Thanks for listening!
smp
|
|
|
Re: Newbie with Tiny68K [message #4152 is a reply to message #4151] |
Fri, 26 January 2018 09:09   |
smp
Messages: 49 Registered: January 2018 Location: Bedford, NH, USA
|
Member |
|
|
Hi all,
I have the source code for a 68K Tiny Basic that is configured to work on an early Motorola trainer. The code is well documented and indicates the portion that would need to be modified for another system:
******************************************************
* The following routines are the only ones that need *
* to be changed for a different I/O environment. *
******************************************************
*
* ===== Output character to the console (Port 1) from register D0
* (Preserves all registers.)
*
OUTC BTST #1,$10040 is port 1 ready for a character?
BEQ OUTC if not, wait for it
MOVE.B D0,$10042 out it goes.
RTS
*
* ===== Input a character from the console into register D0 (or
* return Zero status if there's no character available).
*
INC BTST #0,$10040 is character ready?
BEQ INCRET if not, return Zero status
MOVE.B $10042,D0 else get the character
AND.B #$7F,D0 zero out the high bit
INCRET RTS
*
* ===== Output character to the host (Port 2) from register D0
* (Preserves all registers.)
*
AUXOUT BTST #1,$10041 is port 2 ready for a character?
BEQ AUXOUT if not, wait for it
MOVE.B D0,$10043 out it goes.
RTS
*
* ===== Input a character from the host into register D0 (or
* return Zero status if there's no character available).
*
AUXIN BTST #0,$10041 is character ready?
BEQ AXIRET if not, return Zero status
MOVE.B $10043,D0 else get the character
AND.B #$7F,D0 zero out the high bit
AXIRET RTS
*
* ===== Return to the resident monitor, operating system, etc.
*
BYEBYE MOVE.B #228,D7 return to Tutor
TRAP #14
Since I am not yet a 68K programmer, I asked Bill what changes I need to make to the OUTC and INC routines to connect properly to the Tiny68K Monitor.
Bill replied with this:
Tiny68K uses the trap services of EASy68K. So for console input it is task 5, console output is task 6 and console input pending is task 7. You can also write directly to the 68681 registers, but the advantage of trap is you can simulate your code with EASy68K simulator.
The EASy68K compatible replacement routinte for OUTC & INC:
OUTC:
movem.l d0-d1,-(sp) * save reg d0,d1
move.b d0,d1 * d1 contains the character to send
move.b #6,d0 * console output trap service
trap #15
movem.l (sp)+,d0-d1 * restore register
rts
INC:
movem.l d1,-(sp) * save reg d1
move.b #0,d1 * assuming no input pending
move.b #7,d0 * console ready?
trap #15
move.b d1,d0 * if zero, no input pending, exit
beq done
move.b #5,d0 * otherwise, get data into d1.b
trap #15
move.b d1,d0 * transfer to d0.b
done:
move.l (sp)+,d1 * restore d1
rts
There are no equivalent EASy68K trap services with the auxiliary port, so replace the host I/O with direct write to 68681 registers:
(I'm assuming the serial port B is already properly initialized...)
SRB equ $FFF013 * status reg of serial port B (read)
RHRB equ $FFF017 * Rx holding reg of serial port B (read)
THRB equ $FFF017 * Tx holding reg of serial port B (write)
AUXOUT:
btst.b #2,SRB * wait for transmit ready
beq AUXOUT
move.b d0,THRB * put char out to serial port B
rts
AUXIN:
clr.b d0 * assuming no char input ready
btst.b #0,SRB * does receiver has a char input?
beq hostdone * no input pending, exit with d0.b = zero
move.b RHRB,d0 * get character into d0.b
hostdone:
rts
As you can see the trap services are less efficient, but having the ability to simulate code is worth the overhead.
Bill
With those I/O changes, I was able to get the Tiny Basic to start running, but quite a few more problems have arisen. Stay tuned!
smp
|
|
|
Re: Newbie with Tiny68K [message #4153 is a reply to message #4152] |
Fri, 26 January 2018 09:15   |
smp
Messages: 49 Registered: January 2018 Location: Bedford, NH, USA
|
Member |
|
|
Continuing my effort to get the Tiny Basic to run properly, I re-ORG'd the code to 4000H, and then it was apparently working. At this point, all characters that I type are echoed twice, but the BASIC is receiving the correct entries, and acting upon them. I tried BYE, NEW, and PRINT 1+2, and they all worked appropriately.
It appears that the code is sensitive to where it resides in memory, for some reason. From the beginning, I saw that the author expected the code to be in page 0, because he starts right out assuming the top of memory is only 16 bits:
*
* Modifiable system constants:
*
TXTBGN DC.L TXT beginning of program memory
ENDMEM DC.L $FFFE end of available memory
*
* The main interpreter starts here:
*
CSTART MOVE.L ENDMEM,SP initialize stack pointer
LEA INITMSG,A6 tell who we are
BSR.L PRMESG
MOVE.L TXTBGN,TXTUNF init. end-of-program pointer
MOVE.L ENDMEM,D0 get address of end of memory
That's why I've tried to stay in page 0. ORG at 4000H and top of memory at FFFEH seems to be working at this point, so, hopefully I don't have to crawl through all the code looking for the 16 bit restrictions and opening them up.
Thanks again for listening!
smp
|
|
|
Re: Newbie with Tiny68K [message #4154 is a reply to message #4150] |
Fri, 26 January 2018 09:26   |
smp
Messages: 49 Registered: January 2018 Location: Bedford, NH, USA
|
Member |
|
|
Hi again all,
I decided that the Tiny68K monitor TRAP must echo characters, so I found the one line in Tiny Basic to comment out within the GETLN routine. Double character echo fixed.
It gets a bit bizarre after that. It appears that everything in the Tiny Basic works in direct input mode. It also will let me enter a program, line by line, and LIST will print it all back to me. So far, so good. Then things start to get funny. After typing in one of my favorite test programs, and listing it out, the RUN command hangs. Rats!
I've spent a couple of hours skulking through the code, and nothing obvious (to me, anyway) stands out. I read the reprinted article from Dr. Dobbs, and that shed some light:
"One warning: the DIRECT and EXEC routines were written assuming that the interpreter itself would be somewhere in the first 64K of memory ($0 to $FFFF). If you move it above 64K, you will have to modify the EXEC routine and check the rest of the code carefully to make sure the addressing modes are correct."
So, the author admits to coding this to run only in page 0, and he doesn't know all the bits that will have to be changed to run in a higher page of memory.
I've played around quite a bit with getting the Basic loaded and then executing one or more direct commands, and typing in a program and try to run it. Most all of this playing around results with the RUN command hanging up. I can't recount all the different combinations that I tried, but I finally found this:
Reset the Tiny68K board.
Load the Tiny Basic s-record file.
Type in your program - don't do anything else but type in your program.
Type RUN.
This sequence will get your program to run successfully (if you typed everything in the program correctly).
The next LIST or RUN or PRINT command will hang!
I have Tera Term, so it's pretty easy to load the s-record file to get Tiny Basic running, and then modify the character and line delays to send in my program from a text file. That's how I've been able to try dozens of things and get to this point. I'm starting to doubt the robustness of the Tiny Basic code. Since I am a novice programmer on the 68K, I'd love to have you folks take a look. Maybe someone with more experience programming a 68000 will do better than I have on figuring this out.
Thanks for listening!
smp
[Updated on: Fri, 26 January 2018 09:39] Report message to a moderator
|
|
|
|
|
|
Re: Newbie with Tiny68K [message #4165 is a reply to message #4164] |
Fri, 26 January 2018 17:29   |
plasmo
Messages: 916 Registered: March 2017 Location: New Mexico, USA
|
Senior Member |
|
|
Stephen,
The way the INC routine deals with character-not-ready is unusual. So instead of fighting it and making it works with EASy68K trap services, I just do the direct I/O method. You can see the I/O routines are similar to that of the auxiliary port.
I restored the echo routine you've commented out (BSR GOOUT).
Search for the string **X, those are my modifications to your TinyBasic68Ksmp.X68
I'm not familiar with TinyBasic, but here is my quick test after the modification:
----------------------------------
Gordo's MC68000 Tiny BASIC, v1.3
modified to operate on the Tiny68K board by Bill Shen
OK
> PRINT 23
23
OK
> 100 PRINT 1
> 200 PRINT 2
> 300 PRINT 1+2
> RUN
1
2
3
OK
> LIST
100 PRINT 1
200 PRINT 2
300 PRINT 1+2
OK
> RUN
1
2
3
OK
>
---------------------------------------
[Updated on: Fri, 26 January 2018 17:46] Report message to a moderator
|
|
|
|
Re: Newbie with Tiny68K [message #4168 is a reply to message #4166] |
Sat, 27 January 2018 08:03   |
mikemac
Messages: 250 Registered: March 2017
|
Senior Member |
|
|
smp wrote on Sat, 27 January 2018 06:42Hi Bill,
Well, that certainly turned out to be kind of anticlimactic, didn't it?
Thank you for your attention on this. I'll be trying out that direct I/O code later on today, and I'll try and put the Tiny Basic through some more exhaustive testing.
It remains a mystery to me why the I/O code was the culprit causing the hang up like that...
smp
Basic interpreters often expect the keyboard routine to return even if there is no key pressed. They use that so you can interrupt the running of a program, otherwise you'd have to reset the whole board to break out of the program. I wouldn't be surprised if the routine you tried to use waits for a key to be pressed, thereby hanging the Basic interpreter.
Mike
|
|
|
Re: Newbie with Tiny68K [message #4173 is a reply to message #4168] |
Sat, 27 January 2018 10:12   |
smp
Messages: 49 Registered: January 2018 Location: Bedford, NH, USA
|
Member |
|
|
mikemac wrote on Sat, 27 January 2018 11:03Basic interpreters often expect the keyboard routine to return even if there is no key pressed. They use that so you can interrupt the running of a program, otherwise you'd have to reset the whole board to break out of the program. I wouldn't be surprised if the routine you tried to use waits for a key to be pressed, thereby hanging the Basic interpreter.
Hi Mike, thanks for your thought.
I agree with what you said, but the mystery for me is why would the TRAP service routines for I/O allow one direct command, like PRINT SIZE, and then hang on the second direct command? Or, why would the TRAP service routines allow me to enter a program line by line, and the RUN the program, and then hang on the next direct command? If it were as you said, then wouldn't the TRAP service routines cause a hang right away?
Oh, well, it doesn't really matter, I suppose. I'm just sorry that a new-to-me way of performing I/O didn't work out in this case.
smp
|
|
|
Re: Newbie with Tiny68K [message #4174 is a reply to message #4173] |
Sat, 27 January 2018 10:59   |
smp
Messages: 49 Registered: January 2018 Location: Bedford, NH, USA
|
Member |
|
|
Hello again, all,
I've had the Tiny BASIC up and running for a few hours and it seems to be operating as advertised, once I put in Bill's changes to the I/O routines. So, for anyone who's interested, the code that Bill uploaded here is available for anyone who may want to run Tiny BASIC on their system.
One of my test programs that I use across my vintage machines is a routine to find all the ways to make $1.00 (US) from change (pennies, nickels, dimes & quarters). Here is the code I wrote for the 68K Tiny BASIC::
10 C=0
20 FOR P=0 TO 100 STEP 5
30 FOR N=0 TO 20
40 FOR D=0 TO 10
50 FOR Q=0 TO 4
60 IF P+(N*5)+(D*10)+(Q*25)<>100 GOTO 90
70 PRINT #3,"p=",P," n=",N," d=",D," q=",Q
80 C=C+1
90 NEXT Q
100 NEXT D
110 NEXT N
120 NEXT P
130 PRINT
140 PRINT C," ways to make $1.00 from change"
150 PRINT
With this program, I've "benchmarked" a variety of machines I have, for the fun of seeing how fast or slow they might be. Even the differences between BASICs on the same machine. I was a bit surprised about the difference between the Tiny BASIC and the CB68 compiling BASIC on CP/M 68K:
Tiny BASIC: 2 minutes 6 seconds
CB68: 4 minutes 6 seconds
My timing was by eye on a running digital clock, so the times are probably +/- a second or so, but, wow, I didn't expect 2 minutes difference between the two. The reason probably lies in CB68 performing floating point arithmetic, and Tiny BASIC performing integer arithmetic. I've taken measurements on several BASICs on several machines, and I have results running from 30 seconds to 26 minutes 21 seconds. So, the 8 MHz 68000 here is performing in the better-than-average category, as far as I'm concerned.
I hope that others will try out the Tiny BASIC for themselves. The original .ZIP file has a documentation file, as well as a few programs to tryout.
smp
|
|
|
|
|
|
|
Re: Newbie with Tiny68K [message #4181 is a reply to message #4150] |
Sun, 28 January 2018 05:47   |
smp
Messages: 49 Registered: January 2018 Location: Bedford, NH, USA
|
Member |
|
|
For the benefit of anyone who is interested, here is a complete set of files for the Tiny BASIC with the direct I/O routines.
TinyBasic68Ksmp.X68 - assembler source text file
TinyBasic68Ksmp.S68 - s-record file ready to load
TinyBasic68Ksmp.L68 - assembly listing text file
All these files were generated from the EASy68K assembler application.
Enjoy!
smp
[Updated on: Sun, 28 January 2018 05:51] Report message to a moderator
|
|
|
Re: Newbie with Tiny68K [message #4195 is a reply to message #4177] |
Mon, 29 January 2018 11:56   |
smp
Messages: 49 Registered: January 2018 Location: Bedford, NH, USA
|
Member |
|
|
plasmo wrote on Sat, 27 January 2018 18:33Of course you can speed up performance by putting in a faster CPU with the corresponding oscillator. <...snip...>
I must be doing something wrong. I always try to find parts at several places like Jameco, DigiKey and Mouser. Sometimes I have to experiment to determine how they describe the part that I'm looking for. I determined that I'm looking for a 12 MHz half-can oscillator. I've also tried half-can crystal oscillator, and half-DIP oscillator. I can find some half-can oscillators, but none at 12 MHz or 16 MHz.
Can anyone give me a pointer to a place that I can purchase the required 12 MHz and 16 MHz half-can oscillators to experiment with my board?
Thanks in advance, for any pointers or links that you may be able to provide.
smp
[Updated on: Mon, 29 January 2018 11:57] Report message to a moderator
|
|
|
|
|
|
|
|
|
Re: Newbie with Tiny68K [message #4222 is a reply to message #4215] |
Tue, 30 January 2018 15:36   |
smp
Messages: 49 Registered: January 2018 Location: Bedford, NH, USA
|
Member |
|
|
plasmo wrote on Tue, 30 January 2018 12:49Your board should run at 12 MHz without changing the 68000. When changing the 68000 you need a tool with a bend like this: https://www.ebay.com/itm/New-2-Pairs-Cross-Lock-Tweezers-Sel f-Closing-Fiber-Grip-4-Bent-Straight-tip/321808761311, slide the tool under the IC and gently pry up the 68000. Move forward a little bit and pry up again and repeat until the chip comes clean off. When inserting a new 68000, the row spacing of a new part is too wide for the socket, so you need to bend each row against a hard surface to get the proper row spacing. Align them carefully with the sockets before press it down. Aligning 2 long rows of pins can be tricky. Take your time.
Hi again, Bill, and thanks very much for your advice on the speedup process.
I plan to first try the 12 MHz oscillator. I had hoped that the P8 processor would maybe work. Thanks for verifying that it will.
I had trouble with the link you provided, but I found this:
https://www.amazon.com/TWEEZERS-POINTED-CLOSING-SOLDERING-NO VELTOOLS/dp/B010EAQQFS
Is this what I need?
Thanks a million for all your attention and advice!
smp
|
|
|
|
Re: Newbie with Tiny68K [message #4225 is a reply to message #4223] |
Tue, 30 January 2018 17:49   |
smp
Messages: 49 Registered: January 2018 Location: Bedford, NH, USA
|
Member |
|
|
plasmo wrote on Tue, 30 January 2018 20:34This is the picture of the tweezers I used to remove 68000. You need a way of getting under the device and lift up gently and repeat the process. A small spoon may work as well. <...snip...>
This is the CP2102 board and how I wired in the RTS and CTS. The RTS, CTS are not present on the 6-pin header so I need to build a small adapter board and bring the signals out from the pc board. I think this one from amazon is like mine. <...snip...>
Thanks very much, Bill. I think I have the picture now. One of your pictures shows that there is a silk screen on the underneath of the board - that explains how the description of some of these boards indicates that all the signals are clearly marked, even though in the picture shown they certainly are not.
I'm going to go ahead and order the CP2102 from Amazon. As far as the tool to lift the 68000 out of the socket goes, I understand what you are saying, and I'll see what implement I have that can do the job. I get it - slow and careful will get the job done.
Thanks again!
smp
[Updated on: Tue, 30 January 2018 17:51] Report message to a moderator
|
|
|
Re: Newbie with Tiny68K [message #4227 is a reply to message #4225] |
Wed, 31 January 2018 00:44   |
googlefish
Messages: 3 Registered: April 2016
|
Junior Member |
|
|
I'm the other guy who had problems with CTS/RTS signals and the FTDI adapter.
Now I have two working adapters from amazon:
WINGONEER USB 2.0 to TTL UART 6PIN CP2102 Module Serial Converter
Diymore 2Pcs CP2102 USB 2.0 to TTL UART Module 6-Pin Serial Converter STC Replace FT232 Module
both are working.
They have slight different pin layout, but it's documented on the board.
I use 1:1 connection with these 5 pins, nothing more:
GND
Txd
RxD
CTS
RTS
thanks
Stephan
P.S. sorry no real links, I'm not yet allowed to send them.
[Updated on: Wed, 31 January 2018 00:49] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Current Time: Sat Feb 08 21:54:14 PST 2025
Total time taken to generate the page: 0.00972 seconds
|