English Amiga Board

English Amiga Board (https://eab.abime.net/index.php)
-   Coders. Asm / Hardware (https://eab.abime.net/forumdisplay.php?f=112)
-   -   Serial programming, hardware handshaking (https://eab.abime.net/showthread.php?t=80408)

thec 22 November 2015 21:15

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.

phx 23 November 2015 16:08

Quote:

Originally Posted by thec (Post 1052191)
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.

thec 23 November 2015 17:33

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.

modrobert 24 November 2015 04:35

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.

thec 24 November 2015 09:14

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.

hooverphonique 24 November 2015 11:11

Quote:

Originally Posted by thec (Post 1052324)
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...

thec 24 November 2015 18:10

Quote:

Originally Posted by hooverphonique (Post 1052491)
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?

alkis 24 November 2015 19:49

Quote:

Originally Posted by thec (Post 1052474)
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.

pandy71 24 November 2015 20:13

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

thec 24 November 2015 21:02

Quote:

Originally Posted by alkis (Post 1052559)
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 =)

thec 24 November 2015 21:03

Quote:

Originally Posted by pandy71 (Post 1052568)
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...

pandy71 25 November 2015 10:29

Quote:

Originally Posted by thec (Post 1052581)
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.

hooverphonique 25 November 2015 10:54

Quote:

Originally Posted by thec (Post 1052542)
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.

thec 25 November 2015 19:12

Quote:

Originally Posted by hooverphonique (Post 1052666)
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.

thec 25 November 2015 19:14

Quote:

Originally Posted by pandy71 (Post 1052663)
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.

hooverphonique 26 November 2015 11:17

Quote:

Originally Posted by thec (Post 1052741)
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).


All times are GMT +2. The time now is 11:56.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.

Page generated in 0.05106 seconds with 11 queries