MD RS232 Rx Problem

For hardware talk only (please avoid ROM dumper stuff)
MintyTheCat
Very interested
Posts: 484
Joined: Sat Mar 05, 2011 11:11 pm
Location: Berlin, Germany

MD RS232 Rx Problem

Post by MintyTheCat » Thu Feb 27, 2014 7:20 pm

Hello all,

I am trying to receive Data from the PC side by the Megadrive but I have not been able to get the Megadrive to respond to the Data sent to it.

I am using the Ext-Port (port 3) on a German VA4 Megadrive 1.
I have the MD set as Baud 1200.

I have no problems at all when the MD transmits Data to the PC so that part works at the very least.

I call the SerialRxChar Routine in a continuous Loop.
I have used my Logic-Analyser and I can see that the Characters are transmitted from the PC side with no corruption of framing errors.

My Code performs these steps:

Code: Select all


md_io_port3_ser_sctrl:	equ	$A1001F
md_io_port3_ser_tx:		equ	$A1001B
md_io_port3_ser_rx:		equ	$A1001D
md_io_port3_par_data:	equ	$A10007
md_io_port3_par_ctrl:	equ	$A1000D

...
SeriaInit:
move.B #$B0,axl_md_io_port3_ser_sctrl
...
SerialRxChar:
SerialRxCharInit:
SerialRxCharExec:
Serial_RxChar_RxRdyWait:
  move.B md_io_port3_ser_sctrl,d1
  btst #3,d1
  bne Serial_RxChar_RdDError
  btst #2,d1
  beq Serial_RxChar_RxRdyWait
  move.B md_io_port3_ser_rx,d0
;Serial_RxChar_INFIN_RxRdyGot:
; lea Dummy_MsgGotRxRdy,a5
; jsr Serial_TxString
; bra Serial_RxChar_INFIN_RxRdyGot
Serial_RxChar_RdDError:
  lea Dummy_MsgGotRxDErrory,a5
  jsr Serial_TxString
  bra Serial_RxChar_RdDError
Serial_RxChar_Exit:
  rts 
If I cannot get anywhere with this post then I'll try the other two ports used for the Gamepads and if that still fails then I'll take the MD Modem ROM and disassemble it to get the code that handles the RS232 Receive :D

Does anyone have any Ideas? I can further elaborate on my pins and circuitry if you think that might be something to consider.

Many thanks,

Minty.

MintyTheCat
Very interested
Posts: 484
Joined: Sat Mar 05, 2011 11:11 pm
Location: Berlin, Germany

Post by MintyTheCat » Thu Feb 27, 2014 10:13 pm

I am using a simple Level-Converter using MAX232. Given that I can transmit from the MD I am thinking that my hardware settings are correct. To confirm: should the Tx and Rx => TR, TL be tied to +5vDC?

MintyTheCat
Very interested
Posts: 484
Joined: Sat Mar 05, 2011 11:11 pm
Location: Berlin, Germany

Post by MintyTheCat » Fri Feb 28, 2014 12:46 pm

Ok, I managed to nail it. Essentially you simply wait until RRDY is active then read the Rx Reg.

Thank the mighty Lord for that :twisted:

I took the toshoukan MODEM ROM apart too and found the Code for handling Rx and it confirmed my ideas. The MODEM is configured to 4800 Baud though.

I'll post up some Code if any wants it and I really need to write a Wiki Page on this stuff...

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Fri Feb 28, 2014 12:58 pm

That is a naiss tidbit of info :)
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

MintyTheCat
Very interested
Posts: 484
Joined: Sat Mar 05, 2011 11:11 pm
Location: Berlin, Germany

Post by MintyTheCat » Fri Feb 28, 2014 12:59 pm

TmEE co.(TM) wrote:That is a naiss tidbit of info :)
Do you want the Disassembly for the toshoukan ROM too?

KanedaFr
Administrateur
Posts: 1139
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr » Fri Feb 28, 2014 1:39 pm

I'm very interested in some Serial communication info...
I started to write a KDebug_AlertXXX using serial but didn't find the time to finish it ...mainly because it needed some serial debug

Got my CP2102 adapter waiting on a box just for that ;)

MintyTheCat
Very interested
Posts: 484
Joined: Sat Mar 05, 2011 11:11 pm
Location: Berlin, Germany

Post by MintyTheCat » Fri Feb 28, 2014 1:44 pm

KanedaFr wrote:I'm very interested in some Serial communication info...
I started to write a KDebug_AlertXXX using serial but didn't find the time to finish it ...mainly because it needed some serial debug

Got my CP2102 adapter waiting on a box just for that ;)
Yes, I am writing a Module to add to my Command-Monitor. Essentially, I want the Monitor to sit waiting for Commands and then I want to transfer Data between the Host and the MD to save me having to rebuild and upload umpteen times.

What kind of Environment have you to debug and test? I am using a couple of Bus-Pirates and a Logic-Analyser so I can what goes in and comes out from both sides.

I am planning on using FTDI's RS232RL and I am hoping that I can find a decent Library and API otherwise I shall have to find another solution. Why did you select the CP2102 Device?

KanedaFr
Administrateur
Posts: 1139
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr » Fri Feb 28, 2014 2:54 pm

I dislike FTDI's driver for some reasons (don't remember what! FTDi needs a driver while CP2102 no ? even for basic serial talk) and FTID is more expensive ;)
FTDI ask also its own cable no ?

Well, when I bought mine, there were 3 chip available

FTDI
CP2102
PL-2303

If I mix what I read now and at that time
- PL2303 is just buggy (or at least its driver are) so forget it
- FDTI has an unique serial number that allows use of multiple devices
- CP2102 is/was buggy on last macosx

It seems there is another one from Microship I wasn"t aware of : http://mcs.uwsuper.edu/sb/Electronics/UART/uart3.php

MintyTheCat
Very interested
Posts: 484
Joined: Sat Mar 05, 2011 11:11 pm
Location: Berlin, Germany

Post by MintyTheCat » Fri Feb 28, 2014 3:50 pm

KanedaFr wrote:I dislike FTDI's driver for some reasons (don't remember what! FTDi needs a driver while CP2102 no ? even for basic serial talk) and FTID is more expensive ;)
FTDI ask also its own cable no ?
1. It would help if you could qualify why you did not like FTDI's Driver and let us know which OSs your tried and the Versions if you can.

2. Well all USB Devices have a Driver and a Hook and it really comes down to how the individual OS implements support and how the USB Device connects to the OS.

3. What sort of Prices are we talking about? I simply bought a ready-made PCB as I dislike having to solder. As an Idea you can get a PCB with the FTDI IC RS232RL for something like US$14 - how much would the CP2102 cost? In real terms I have no problems spending $14.

4. the FTDI IC PCB that I bought uses a standard USB Cable - which Cable were you referring to and is it special?
Well, when I bought mine, there were 3 chip available

FTDI
CP2102
PL-2303

If I mix what I read now and at that time
- PL2303 is just buggy (or at least its driver are) so forget it
- FDTI has an unique serial number that allows use of multiple devices
- CP2102 is/was buggy on last macosx

It seems there is another one from Microship I wasn"t aware of : http://mcs.uwsuper.edu/sb/Electronics/UART/uart3.php
It really comes down to what you want to do with the USB<->RS232 Device. I have a device ready for a normal Serial Terminal Session but I want something that I can write my own Applications with and this entails writing a Driver. I shall write for Linux.

Please let us know your answers and further elaborations, kaneda.

Cheers,

Minty.

KanedaFr
Administrateur
Posts: 1139
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr » Thu Mar 13, 2014 9:52 am

I think it was because it wasn't clear if the FDTI chip needed a driver even for basic serial communication

for me, you can connect the CP102 and you'll see a serial port mounted on Windows while with the FDTI, you'll need to install a driver first

IT WAS SOME YEARS AGO, before windows 7 and 8.x
So it's perhaps no longer true


Regarding serial, can you tell me how much char you can send and when ?
I mean

is it possible to send char while hint ? if yes, how many ?
is it possible to send char while vint ? if yes, how many ?
is it possible to send char outside int ? if yes, how many ?

I also plan to try the 4bit protocol like Mt. Chocolate did (http://68000.web.fc2.com/sram.html)
But I wonder how I could handle high speed if I can push more than interrupts timing allows....

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Thu Mar 13, 2014 10:16 am

It takes some 30 lines to transfer a byte over 4800 baud serial link.
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

KanedaFr
Administrateur
Posts: 1139
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr » Fri Mar 14, 2014 10:37 am

Wow, a little hard so create a "real" communication.

I mean, how could you call something like

Serial_send("Hello, I'm a very long string and my goal is to make your game lag like hell");
Serial_receive(); //"Sorry, you're out of time, you're already on another frame (if not 2)"

MintyTheCat
Very interested
Posts: 484
Joined: Sat Mar 05, 2011 11:11 pm
Location: Berlin, Germany

Post by MintyTheCat » Fri Mar 14, 2014 9:19 pm

KanedaFr wrote:Wow, a little hard so create a "real" communication.

I mean, how could you call something like

Serial_send("Hello, I'm a very long string and my goal is to make your game lag like hell");
Serial_receive(); //"Sorry, you're out of time, you're already on another frame (if not 2)"
Kind of depends on what you want to use the Serial Ports for. You can send small amounts of status information for a game like Lethal-Enforces or something like that.

I use it to send S-Records from the PC to the Megadrive for Executable blobs of Code and I use it to send data to and from the PC and MD.

Essentially, I use it to try level ideas out.

What you need to do with your little Tx Rx Scenario above is to have some kind of Semaphore to block you from receiving the next message on the transmitting side. Using a good Communication Method is a good idea such as terminating all Messages with a certain Character such as a double ## or something like that.

MintyTheCat
Very interested
Posts: 484
Joined: Sat Mar 05, 2011 11:11 pm
Location: Berlin, Germany

Post by MintyTheCat » Fri Mar 14, 2014 9:21 pm

I am looking at making a Link between the PC and MD and a control program and a Driver.

If anyone fancies helping then we can discuss it further, if not then I will probably not share the Code with the Community once I've completed it - your choice.

MintyTheCat
Very interested
Posts: 484
Joined: Sat Mar 05, 2011 11:11 pm
Location: Berlin, Germany

Post by MintyTheCat » Fri Mar 14, 2014 9:34 pm

KanedaFr wrote:I think it was because it wasn't clear if the FDTI chip needed a driver even for basic serial communication
As I recall it is ready to use with Linux and OS X 10.6.(I forget).

Windows it installs its own Driver when you plug in - at least for XP.
KanedaFr wrote:for me, you can connect the CP102 and you'll see a serial port mounted on Windows while with the FDTI, you'll need to install a driver first
Might be an issue that you had, I have no troubles with FTDI under Windows XP.
KanedaFr wrote:IT WAS SOME YEARS AGO, before windows 7 and 8.x
So it's perhaps no longer true
Never used 7 or 8 and will most likely never use them - you need to use a proper Operating-System like BSD, Linux or Solaries, Kaneda :D
KanedaFr wrote: Regarding serial, can you tell me how much char you can send and when ?
I mean

is it possible to send char while hint ? if yes, how many ?
is it possible to send char while vint ? if yes, how many ?
is it possible to send char outside int ? if yes, how many ?
I think that conducting a proper set of tests with Results would be a good idea. We shall need a place to store the results too for all to see.

Quick reply: The Interrupt can be used to inform the 68K that the Serial has interrupted - the 68K can ignore it if set or can react, the actual hardware of the UART is not part of the 68K and it has its own timing and framing hardware going on so you only need to accept when the port is ready to receive/etc.
KanedaFr wrote:I also plan to try the 4bit protocol like Mt. Chocolate did (http://68000.web.fc2.com/sram.html)
But I wonder how I could handle high speed if I can push more than interrupts timing allows....


Yes, you could knock up a simple Circuit using some HCT 373 ICs and perhaps a 244 or something like that and then simply multiplex with a 138 or something similar. Pick up any book on Parallel Interfacing/Centronics and you'll see that type of Circuit but if you cannot then reply to this Thread and I'll find you a circuit.

The other thing is that you will have to write control software for the Parallel Port and set the mode - I dare say it will not be EPP or ECP but standard Parellel so use that. It is hardly likely to be fast in terms of your host PC's clock so you need to work out how to respond to events using something like a Signal or something similar so although you have no need to write a Driver you will still need to write control Software on your Host and indeed on the MD Side too.

I hope that makes sense.

As I said, I am open to us all working collaboratively to make a MD Link for the Host Operating-System(s).

Cheers.

Post Reply