Finally managed to interface to a SDcard to the Arduino. There are several "tutorials" and even libraries written for the Arduino, but my objective was not to use any Arduino library or specific feature (like the integrated SPI port), otherwise porting the code to the mini68k would be more difficult.
I started with this example (this other seems easier) and then started "removing stuff" in order to fit my purposes. I only need the basic initialize, read sectors and write sectors. In order to boot and run CP/M from an SDcard I don't even need to read/write more than a single sector as CP/M reads/writes only one sector, furthermore deblocking (breaking up a 512 byte sector into 128 byte CP/M sectors) is easily managed by most CP/M flavours (CP/M-80,CP/M-86,CP/M-68k, CP/M-Z8000).
I battled with some Arduino functions, I particular serial.print() functions. I'm suspicious that something doesn't quite add up, some of the lines of text that should be printed are skipped for no apparent reason. It could be by the fact that I directly access the port pins (DDRB and PORTB) but since I don't change the serial pins there shouldn't be a problem...
After several tries I managed to write and read a sector of the flash.
Pins CD and WP are also connected directly, the card detect(CD) and write protect(WP) switches use a weak pull up feature from the micro. A low voltage drop regulator provides 3.3V to the card.
I used the Sparkfun SDcard adaptor, but since the "freeday disappointment" I promissed never to buy from them until the EURO is >= 2x the US dollar (from that point on I would be stupid, not stubborn). The circuit used is the one of the first example above, except that I didn't bother to have the correct 3.3V input, I decided to go to 2.5V as it is easier to obtain (two equal resistors) and the input tolerance of the SDcard must accept it correctly. Usual (CMOS) input levels are at 60% (2.2V for High or 1) and 30% (for Low or zero) of Vcc (of the card).
Now I only need to port the code to the 68k...
5 weeks ago