The pulse generator is in the IRQ. The timer has several compare registers. The first is responsible for the pulse width - not important. The second one determines the delay till the next pulse - actual data payload. The original code from Cyclone20 did all the processing of the data stream inside the IRQ service routine: mostly the delay till next pulse but also commands like stop writing, wait till an index pulse, etc.Jeff wrote: so, the pulse generator routine is in the main loop ?
Strangely, putting it in a NMI/timer style irq seems to me a better way to avoid this kind of problem.
Maybe there are not the time budget to call an irq to generate each pulse?
When I first saw the problem I added code to set an unused pin when entering the routine and reset it at the exit. The scope showed that at full (DD) rate writing a track spent about 50% of the time servicing the interrupt. This told me that:
1. the routine was not the problem
2. this won't work for an HD stream
Now the IRQ routine is a lot smaller as it doesn't try to interpret the commands in the stream and can be re-coded in assembly if needed for the HD. (If anyone decides to do it.)
Here is my plan. Please comment as you did several implementation already.
All the commands will go over the command endpoint: reset the buffer, start storing data coming from the EP1 to the buffer, spin up, wait for the index, etc.
The MFM stream for one full track will be stored in a buffer. With 64K RAM there is plenty of room even for an HD track.
Once the writing starts, the IRQ happens every time a new pulse starts. At this time we should calculate the delay till the next pulse by shifting the buffered data and setting the new timer value. Very fast.
The same procedure will be used for both writing to a real floppy and emulating one.
Why do it at all if a PIC version is available? First of all I want to add Apple 2 format and I feel a lot more comfortable with a lot of RAM and MIPS to burn. Second the built-in USB is nice. Using an inexpensive SAM7S256 board ready made that has both an MMC/SD connector and USB it should be possible to combine the functionality of both HxC variations.