RS-232 Read/Write from Machine Language

Basic and Machine Language

Moderator: Moderators

Post Reply
User avatar
k3ys
Vic 20 Amateur
Posts: 43
Joined: Thu Mar 26, 2015 3:34 pm

RS-232 Read/Write from Machine Language

Post by k3ys »

Are there any source examples out there for reading from and writing to the RS-232 port from assembly?
User avatar
srowe
Vic 20 Scientist
Posts: 1325
Joined: Mon Jun 16, 2014 3:19 pm

Re: RS-232 Read/Write from Machine Language

Post by srowe »

Do you mean directly or via KERNAL calls? I've written a prog that accepts Intel HEX from the serial port and writes it to memory using KERNAL routines.
User avatar
k3ys
Vic 20 Amateur
Posts: 43
Joined: Thu Mar 26, 2015 3:34 pm

Re: RS-232 Read/Write from Machine Language

Post by k3ys »

KERNAL calls are fine. In fact preferred, I think. I want to keep the code small. 192 bytes in the cassette buffer.
User avatar
beamrider
Vic 20 Scientist
Posts: 1447
Joined: Sun Oct 17, 2010 2:28 pm
Location: UK

Re: RS-232 Read/Write from Machine Language

Post by beamrider »

Any examples that can read/write at 9600 baud would be fantasic for using (configuring) the 10$ ethernet adapter...
User avatar
srowe
Vic 20 Scientist
Posts: 1325
Joined: Mon Jun 16, 2014 3:19 pm

Re: RS-232 Read/Write from Machine Language

Post by srowe »

Here's my complete program, the setup of the serial port is near the start. I tripped over a 'feature' that BASIC works around. The OPEN call returns with Cb set and $F0 in .A on success, it's a side-effect of calling MEMTOP at the end of OPENRS...
beamrider wrote:Any examples that can read/write at 9600 baud would be fantasic for using (configuring) the 10$ ethernet adapter...
I've only used 1200 baud. It should work up to 2400 baud, beyond that I don't think the software implementation of the 6551 is stable.
Attachments
ihex.zip
(1.81 KiB) Downloaded 69 times
User avatar
joshuadenmark
Big Mover
Posts: 1217
Joined: Sat Oct 23, 2010 11:32 am
Location: Fr-Havn, Denmark
Occupation: Service engineer

Re: RS-232 Read/Write from Machine Language

Post by joshuadenmark »

Just ran a setup at 1200 baud rate from windows 10 - seemed to work :D

Module used: [USR-TCP232-2] Serial RS232 to Ethernet TCP/IP Converter Module http://www.usriot.com/Product/24.html
baudrate windows10.jpg
baudrate windows10.jpg (35.24 KiB) Viewed 2182 times
setup tcp232.jpg
setup tcp232.jpg (107.72 KiB) Viewed 2182 times
This post actually should be moved to this thread, my mistake:
http://sleepingelephant.com/ipw-web/bul ... =11&t=7464
Kind regards, Peter.
____________________________________________________
In need of a wiki logon - PM me
User avatar
beamrider
Vic 20 Scientist
Posts: 1447
Joined: Sun Oct 17, 2010 2:28 pm
Location: UK

Re: RS-232 Read/Write from Machine Language

Post by beamrider »

Isn't that setting it to1200, the setup process would be conducted at 9600 by the software?

Sent from my Nexus 5 using Tapatalk
User avatar
joshuadenmark
Big Mover
Posts: 1217
Joined: Sat Oct 23, 2010 11:32 am
Location: Fr-Havn, Denmark
Occupation: Service engineer

Re: RS-232 Read/Write from Machine Language

Post by joshuadenmark »

kind of both - I've set the COM3 (in windows) to 1200 baud and ran the setup tool and then set the card to 1200 baud too.

But I doesn't know if this program can override the windows setting for COM3 port?
Kind regards, Peter.
____________________________________________________
In need of a wiki logon - PM me
User avatar
beamrider
Vic 20 Scientist
Posts: 1447
Joined: Sun Oct 17, 2010 2:28 pm
Location: UK

Re: RS-232 Read/Write from Machine Language

Post by beamrider »

Yes, its a parameter in the win32 openfile API.

Sent from my Nexus 5 using Tapatalk
User avatar
beamrider
Vic 20 Scientist
Posts: 1447
Joined: Sun Oct 17, 2010 2:28 pm
Location: UK

Re: RS-232 Read/Write from Machine Language

Post by beamrider »

Try a terminal emulator like Realterm set it to 1200 or 2400 and try to configure it manually with the config string. I'd be surprised if it works.

Sent from my Nexus 5 using Tapatalk
User avatar
joshuadenmark
Big Mover
Posts: 1217
Joined: Sat Oct 23, 2010 11:32 am
Location: Fr-Havn, Denmark
Occupation: Service engineer

Re: RS-232 Read/Write from Machine Language

Post by joshuadenmark »

First a connection with SyncTerm to the BBS (IP show in post above) - something is working - at a slow rate - when it stopped I pressed Enter and some more characters showed up.
connected 1200 Baud.jpg
connected 1200 Baud.jpg (48.29 KiB) Viewed 2161 times
Kind regards, Peter.
____________________________________________________
In need of a wiki logon - PM me
User avatar
beamrider
Vic 20 Scientist
Posts: 1447
Joined: Sun Oct 17, 2010 2:28 pm
Location: UK

Re: RS-232 Read/Write from Machine Language

Post by beamrider »

That looks like garbage caused by an incorrect baud rate to me.

Use a loopback connector (I use a paper clip to poke in the tx and rx connectors ;) ) to check that you have successfully configured the device (@1200 baud) to talk (@1200 baud).

Use the terminal emu, set the baud rate to 1200 (and switch off local echo) and you should be able to type characers and see them on screen.
User avatar
k3ys
Vic 20 Amateur
Posts: 43
Joined: Thu Mar 26, 2015 3:34 pm

Re: RS-232 Read/Write from Machine Language

Post by k3ys »

srowe wrote:Here's my complete program, the setup of the serial port is near the start. I tripped over a 'feature' that BASIC works around. The OPEN call returns with Cb set and $F0 in .A on success, it's a side-effect of calling MEMTOP at the end of OPENRS...
beamrider wrote:Any examples that can read/write at 9600 baud would be fantasic for using (configuring) the 10$ ethernet adapter...
I've only used 1200 baud. It should work up to 2400 baud, beyond that I don't think the software implementation of the 6551 is stable.
Thanks srowe, this is very helpful.

Keys
Post Reply