Amiga error validating disk
So at this point I wrote a disk image out I had created previously, and then tried to read it back. Either the data I had written was invalid, or the way I was writing it was wrong.
I decided to feed the encoded MFM sector data that I was creating into my sector decoding algorithm used by the reader to validate that what I was generating was correct and valid, and it was.
So there should be time, assuming the code loop is tight enough and the operating system doesn't delay the sending and receiving too much. The entire read/write cycle took far too long, well beyond one revolution of the disk.
The Arduino side was probably fast enough, but the OS wasn't responsive enough.
So this seemed to work, and the Arduino completed the write without losing any data from the computer. I found that in order to move the drive head back and forth you first had to raise the /WRITE GATE pin, I suspected this was required for changing the surface also.
I also didn't know which direction these pins were actually in, but after some experimentation, I found the CTS pin could be signaled from the Arduino and used by the PC to control the flow.
Normally this is done using a circular buffer, but in my case I couldn't allow this, so I simply set it to '1' when I don't want data, and '0' while I do.
I decided to check between each bit write if another byte had been received since CTX went high and store it.
My theory was that when you raised CTX, the computer was probably already in the middle of transmitting the next byte and as you can't stop it mid-stream, then it would half after this one.The only questions now were: has it actually written any data, and if so, is any of it valid? Once I added code to do this the drive head moved as expected.At this point I had only encoded one track, so I decided to run the entire algorithm to encode all 80 tracks. This did make sense and would prevent accidental writing of tracks while moving the head around.I suspected that changing the status of the CTX line didn't instantly stop the flow of data and the computer may still send a character or two.