James Stanley


SCAMP works at 1 MHz

Sat 29 May 2021
Tagged: cpu, electronics

Thanks to Rory's suggestion of CD4504 TTL-to-CMOS level shifters, last night I finally succeeded in moving the CompactFlash glue logic out of the Arduino and into physical hardware.

Since I no longer need the Arduino code to sync anything to the clock signal, I'm free to use the CTC to generate it, which can give a much higher frequency. I used TimerOne to generate a 1 MHz square wave (which is the maximum as far as I can tell), and the SCAMP hardware still appears to function correctly, which is great news.

Here's a recording of a session running on the real hardware (it's 6 minutes long so maybe you don't want to watch it all):

Performance

I know it seems quite slow, but consider that previously it took about 30 minutes just to boot up to the shell, and now it's almost usable interactively. Things are moving in the right direction.

There is potentially scope to clock it even higher, and there are definitely software improvements to be made. For example the kernel's CompactFlash reading/writing code is all written in SLANG at the moment, which produces extremely unoptimised code. Eventually I'll rewrite the inner loops in assembly language.

Obvious problems

The first obvious problem is the garbled text at the start. This is text output from the bootloader and kernel, and the reason it is garbled is because the CPU is now running fast enough that it tries to stuff characters into the UART faster than they can be transmitted! I didn't expect to run into this problem so early, but it should be straightforward to fix, either by adding a bunch of slownop in the worst case, or preferably by polling the UART status.

The second problem is that the space bar doesn't seem to work properly. I can not explain this. I didn't observe any flipped bits in any other keypresses, so it is hard for me to imagine what is going on. Sometimes pressing the space bar puts nothing on the screen, but invisibly terminates your input command line. It acts as if the space bar sometimes inserts a 0x00 instead of 0x20. Not sure what's happening, but I look forward to debugging it.

Next steps

The immediate next step is to turn this mess of wires into a PCB:

I'm very pleased to be at the point where the UART and the CompactFlash card are both working correctly. I have found interfacing with the peripherals to be the most complicated part of building the computer, because they are rather inscrutable black boxes that are hard to faithfully recreate in the emulator.

I think I might provide for 2 CompactFlash cards on the PCB. One would be purely internal and hold the kernel and root filesystem, and the other would be removable through the front panel, as a convenient way to transfer files between the SCAMP and a modern computer. The kernel doesn't yet support more than 1 block device, and I'm not exactly sure how I would support it. It might be simpler to have a "userspace" program responsible for interacting with the removable device, rather than mounting it on the filesystem.

It's probably about time that I looked at building a proper clock circuit. I'm curious to know how fast it can be clocked before it gets unstable.

And I still need to work on the wooden case that I keep talking about, fit a proper power supply inside it, and make a PCB for the clock, and the power & reset switches.



If you like my blog, please consider subscribing to the RSS feed or the mailing list: