Page 1 of 1

Getting the INP command to work

PostPosted: December 28th, 2015, 1:54 am
by Snudge
I have just received my new clone and it works very nicely. I have successfully written some small machine code programs, connected up to a PC working as a terminal, loaded disk basic and 'printed' to the second serial port using LPRINT.

However, I would like to use the second serial port to receive data in a BASIC program and I understand that I can use the INP command to do this. I know that this will be slow but I can arrange for bytes to be sent as slowly as necessary. My problem is that I can't get it to work at all and the manual doesn't give much detail on the subject.

Using the monitor I can see that my serial ports are configured as follows:

1 2SIO 020,021 9600
2 2SIO 022,023 9600
3 SIO 006,007 300

In BASIC, if I use an OUT command like this:

10 OUT 3,65

...I get an 'A' coming out of the second serial port at 9600 baud. However, if I put an 'A' into the second serial port at 9600 baud while running something like this:

10 A=INP(3)
30 GOTO 10

...i just see the number 13 over and over again. I would have expected to see at least one 65.

My questions are:

1. Why is the OUT command sending characters to the 2nd serial port when I specify a port number of 3? It's not a problem but I would have expected either 1 or 2 to have been the correct values.
2. Why do I see character 13 coming in on port 3? (I have tried port values of 0,1 and I get 255 and on port 2 the number I get is 15)
3. How do I get INP to work properly?

Many thanks for any pointers!

Re: Getting the INP command to work

PostPosted: December 28th, 2015, 2:55 pm
by AltairClone
Keep in mind that virtually everything about the Altair Clone works like the real Altair. You'll want to look at the manual for the Altair 88-2SIO board to understand how to use the serial port in your Altair. As you list the current configuration of your Altair, it is set up as follows:

The top serial port connector is an 88-2SIO serial port at octal I/O address 20 & 21 (use decimal addresses of 16 and 17 to access in BASIC).

The bottom serial port connector is an 88-2SIO serial port at octal I/O address 22 & 23 (use decimal addresses of 18 and 19 to access in BASIC).

The third serial port from the cassette interface board is an 88-SIO board at I/O address 6 & 7.

In the Clone, the 88-LPC printer parallel port is always at its default I/O address of 2 & 3. As covered in the Altair Clone manual in section "D. Line Printer Port" starting on page 2, the Clone routes data that software may write to the 88-LPC I/O address through the 2nd serial port on the Clone. This is because virtually nobody has a printer that a real 88-LPC interface could drive, so the output is routed through the 2nd serial port on the Clone so a terminal or terminal emulator can be used to see what old software may have been writing to the line printer. This output is done independent of "real" serial port I/O (configured as a 2SIO port in your case). Old Altair software does not use I/O addresses 2 & 3 as a serial port, the software thinks it's writing to a printer parallel port. This port, in turn, does not provide any mechanism for input.

When you issue "OUT 3, 65" you are sending an "A" to the 88-LPC data output port. The Clone routes this through the 2nd serial port for you. The 88-LPC does not support input on the data port so what you read on an "INP(3)" is undefined.

In your configuration, you could also issue "OUT 19,65" to send an "A" to the 2nd 88-2SIO serial port which is the 2nd serial port on your clone. To read data from the second serial port, you'll want to do an INP(19), not an INP(3).

But... you cannot send data until the serial port is ready to accept more data, so you should wait for the TDRE flag in the 2SIO status register to be asserted before sending each character (e.g., WAIT,18,2). Likewise, you shouldn't do an INP for data until a character has been received (e.g. WAIT,18,1).


Re: Getting the INP command to work

PostPosted: December 28th, 2015, 5:41 pm
by Snudge
Many thanks - it is all working now! Your explanation has made it a lot clearer.