English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 22 November 2015, 21:15   #1
thec
 
Posts: n/a
Serial programming, hardware handshaking

Hey. Beginner Amiga (and Motorola) coder here.

I have some serial communication going on in assembler on the Amiga, and some send/receive on my PC. It's running in 9600 baud on a 040 accelerated Amiga 1200 with minor problems, but it's without hardware handshaking, checking the register SERDATR for incoming data and resetting INTREQ bit 11. When sending, writing to SERDAT with stop bit and waiting for bit 13 of SERDATR to clear (though I should probably switch those two operations )

The PC side was quite straight forward, but when I turn on hardware handshaking the transfer just hangs. Questions:

* Is the Amiga capable of this?
* Do I need to do something else than what is described in the hardware manual from page 250 and onward (what I described above).
* Any idea why it halts?

The Amiga code:
http://pastebin.com/1BYjr01P

The PC code:
http://pastebin.com/yR7isyxv

Would be cool with faster baud rates but also to run on slower Amigas...

Why? Why not? :-)

PS. If somebody has some serial programming reference code I would love to see it! Ds.

Last edited by thec; 23 November 2015 at 08:02.
 
Old 23 November 2015, 16:08   #2
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Quote:
Originally Posted by thec View Post
It's running in 9600 baud on a 040 accelerated Amiga 1200 with minor problems, but it's without hardware handshaking,
IIRC it should be able to reach 38400 or even 57600 with RTS/CTS on a 040/25MHz CPU. A 060 can do 115200.

Quote:
checking the register SERDATR for incoming data and resetting INTREQ bit 11. When sending, writing to SERDAT with stop bit and waiting for bit 13 of SERDATR to clear (though I should probably switch those two operations )
If you intend to reduce the system load I would suggest to implement an interrupt routine instead of doing busy-waiting.


Quote:
The PC side was quite straight forward, but when I turn on hardware handshaking the transfer just hangs. Questions:

* Is the Amiga capable of this?
You can do RTS/CTS handshaking, but I wouldn't call it "hardware handshaking", as you have do drive the lines manually with CIA-B.

Quote:
* Do I need to do something else than what is described in the hardware manual from page 250 and onward (what I described above).
No. You find the hardware-handshaking lines in port register A of CIA-B - refer to page 318.

Quote:
* Any idea why it halts?
I didn't look into it too closely. Problems with the multitasking?

EDIT: Just saw you wrote that you're a beginner, so you're probably not hitting the hardware for fun? I should mention that there is also serial.device, which works fine. Certainly faster than 9600 bps on a 040.

Last edited by phx; 23 November 2015 at 16:12. Reason: serial.device
phx is offline  
Old 23 November 2015, 17:33   #3
thec
 
Posts: n/a
Thanks for your reply!

Messing around with the CIA-B seems to be over my head right now but perhaps writing an interrupt routine would be a good step for me to try.

To be honest I haven't tried 38400/57600 but I tried 19200 and got far too many errors even there, but there are some optimizations I could do in the code too I guess, to fine tune the performance.

Yeah I'm poking the hardware with my beginner stick, but having lots of fun in the meantime. I do this in pure asm, serial.device is a c library no? Anyhow, it's working, I just want it to perform better for no particular reason, but as you suggested, writing a interrupt might be doable.
 
Old 24 November 2015, 04:35   #4
modrobert
old bearded fool
 
modrobert's Avatar
 
Join Date: Jan 2010
Location: Bangkok
Age: 56
Posts: 775
From my experience with the Amiga serial port...

You get 19200 Baud on an Amiga (A500/A1000/A2000) with 68000 CPU (@ 7MHz) using standard serial device (WB 1.2 or WB 1.3) and decent terminal program (eg. JR-Comm), 38400 Baud can be achieved with faster serial device and tweaking screen mode (number of colours), etc.

A plain A1200 gives you 57600 Baud using standard serial device (WB 3.1) and decent terminal program (eg. NComm), with any accelerator (020/030 CPU) over ~30Mhz you can do 115200 Baud.

The "hardware" part of RTS/CTS refers to the physical RS-232 pins in the serial port to handle the handshake, as opposed to XON/XOFF handshaking which is "soft" as in characters sent by software in the data flow.

I haven't done any serial programming on the Amiga, so can't help much there.
modrobert is offline  
Old 24 November 2015, 09:14   #5
thec
 
Posts: n/a
Thanks anyway, the performance is interesting information!

Didn't think about switching screenmode to gain a few cycles, good idea.

Can't run WB, I run my program on boot, it waits for a package to be received from the PC, unpacks it and runs the executable from it, that way I can set up a programming environment on the PC but run on the real hardware. It works already, just wanna fine tune the transfer... works good on the accelerated 1200, but the stock 1200 doesn't run as smoothly, but I suspect 19200 should be achievable with it from your tests.. I'll optimize the code

Like this: https://www.facebook.com/thec77/vide...5/?pnref=story only I wrap my code with Makefiles and send it to the amiga with the install script.
 
Old 24 November 2015, 11:11   #6
hooverphonique
ex. demoscener "Bigmama"
 
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
Quote:
Originally Posted by thec View Post
Yeah I'm poking the hardware with my beginner stick, but having lots of fun in the meantime. I do this in pure asm, serial.device is a c library no? Anyhow, it's working, I just want it to perform better for no particular reason, but as you suggested, writing a interrupt might be doable.
serial.device is an amiga os device, which can be used from all programming languages.

since you're hitting the hw directly, have you shut the system down properly? otherwise the os may interfere with what you're doing...
hooverphonique is offline  
Old 24 November 2015, 18:10   #7
thec
 
Posts: n/a
Quote:
Originally Posted by hooverphonique View Post
serial.device is an amiga os device, which can be used from all programming languages.

since you're hitting the hw directly, have you shut the system down properly? otherwise the os may interfere with what you're doing...
My program is run from startup-sequence and no workbench, is there still a need to shut down stuff? May I have some suggestions on what to shut down and how?
 
Old 24 November 2015, 19:49   #8
alkis
Registered User
 
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
Quote:
Originally Posted by thec View Post
Like this: https://www.facebook.com/thec77/vide...5/?pnref=story only I wrap my code with Makefiles and send it to the amiga with the install script.
Nice!

One obvious speedup would be compression.
alkis is offline  
Old 24 November 2015, 20:13   #9
pandy71
Registered User
 
Join Date: Jun 2010
Location: PL?
Posts: 2,748
Go for floppy port - HW and faster than UART - 250/500kbps should be supported by most good UART2USB (almost sure it should be supported by FTDI).

btw http://aminet.net/package/comm/misc/easytransfer

Last edited by pandy71; 24 November 2015 at 20:22.
pandy71 is offline  
Old 24 November 2015, 21:02   #10
thec
 
Posts: n/a
Quote:
Originally Posted by alkis View Post
Nice!

One obvious speedup would be compression.
Yepp, I pack in my install script and run a executable inside the archive on the amiga (unpack the whole thing). The video was just the first running thing =)
 
Old 24 November 2015, 21:03   #11
thec
 
Posts: n/a
Quote:
Originally Posted by pandy71 View Post
Go for floppy port - HW and faster than UART - 250/500kbps should be supported by most good UART2USB (almost sure it should be supported by FTDI).

btw http://aminet.net/package/comm/misc/easytransfer
Floppy port.. interesting...

.. yeah, of course there is similar programs out there now that I spent the whole month for research and coding, but, since coding for the amiga is just for kicks anyway, no problem :-)

As a complete n00b (didn't even own one back in the day) these things are not easy to find...
 
Old 25 November 2015, 10:29   #12
pandy71
Registered User
 
Join Date: Jun 2010
Location: PL?
Posts: 2,748
Quote:
Originally Posted by thec View Post
Floppy port.. interesting...
Floppy is more interesting as HW provide data transfer (critical from Amiga perspective) - CIA GPIO can be used to perform handshake and with block transfer relatively fast bitrate achieved all this with relatively low CPU usage - crucial from plain 68000&7MHz.
In case of Amiga UART, Copper can be used to output data (as such fast Tx rate) but problem is R(x)eception - UART in Paula is not buffered like 16550 on PC (16 byte FIFO) and every byte will create interrupt - this can kill multitasking efficiently - perhaps block oriented transfer may help a bit but still - this is serious limitation for vanilla Amiga.

Btw - level (voltage) translator used in Amiga (old 1488/1489) can be serious limitation - it can be desired to replace them with something more modern (faster) for example MAX232 like IC's- when FDD serial is used this not a limitation - just use FTDI232 with TTL level translator.
pandy71 is offline  
Old 25 November 2015, 10:54   #13
hooverphonique
ex. demoscener "Bigmama"
 
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
Quote:
Originally Posted by thec View Post
My program is run from startup-sequence and no workbench, is there still a need to shut down stuff? May I have some suggestions on what to shut down and how?
the cia interrupt register (icr) is cleared when read, this means that if the os reads this register, it could clear any pending interrupt requests, and then your code could miss it.. if you bang the hw directly, you should shut down the os (like demos/intros do), or maybe use SetICR of cia.resource to poll for interrupt requests.
hooverphonique is offline  
Old 25 November 2015, 19:12   #14
thec
 
Posts: n/a
Quote:
Originally Posted by hooverphonique View Post
the cia interrupt register (icr) is cleared when read, this means that if the os reads this register, it could clear any pending interrupt requests, and then your code could miss it.. if you bang the hw directly, you should shut down the os (like demos/intros do), or maybe use SetICR of cia.resource to poll for interrupt requests.
But if I shut down INTENA such as demos do, I need to keep intterupt at bit 11 (receive buffer full) on, right?

Unrelated, I'm having a strange error now in my code, I'll post about it later.
 
Old 25 November 2015, 19:14   #15
thec
 
Posts: n/a
Quote:
Originally Posted by pandy71 View Post
Floppy is more interesting as HW provide data transfer (critical from Amiga perspective) - CIA GPIO can be used to perform handshake and with block transfer relatively fast bitrate achieved all this with relatively low CPU usage - crucial from plain 68000&7MHz.
In case of Amiga UART, Copper can be used to output data (as such fast Tx rate) but problem is R(x)eception - UART in Paula is not buffered like 16550 on PC (16 byte FIFO) and every byte will create interrupt - this can kill multitasking efficiently - perhaps block oriented transfer may help a bit but still - this is serious limitation for vanilla Amiga.

Btw - level (voltage) translator used in Amiga (old 1488/1489) can be serious limitation - it can be desired to replace them with something more modern (faster) for example MAX232 like IC's- when FDD serial is used this not a limitation - just use FTDI232 with TTL level translator.
I understood some of those words.... Well, until I'm fed up with it, I'm running serial, so I'm gonna try to run that as smooth as possible.
 
Old 26 November 2015, 11:17   #16
hooverphonique
ex. demoscener "Bigmama"
 
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
Quote:
Originally Posted by thec View Post
But if I shut down INTENA such as demos do, I need to keep intterupt at bit 11 (receive buffer full) on, right?

Unrelated, I'm having a strange error now in my code, I'll post about it later.
Just ignore my rambling.. somehow I'd forgot that the UART is located in paula, not the cia's (they only take care of CTS,DTR,DTS,etc).

Last edited by hooverphonique; 26 November 2015 at 11:22.
hooverphonique is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
My Amiga Hardware Programming site is up! Photon Coders. Asm / Hardware 28 12 June 2015 14:16
Serial programming in ACE basic on A600. vext01 Coders. System 5 27 August 2014 23:34
Best practices for direct hardware programming ? weiju Coders. Asm / Hardware 27 31 October 2011 13:10
new hardware suggestion: USB to serial mouse adapter gizmomelb support.Hardware 15 22 December 2006 01:24
Hardware port programming. CLK on parallel. redblade Coders. General 0 29 March 2005 11:19

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 05:48.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.10113 seconds with 13 queries