Sorted by Squirrels.

Thursday, 18 June 2009

AtoMMC 2.0

What's going on here then?



Let's see ... that's:

Acorn Atom Rev.4 with PL8 fitted +
Microchip PIC 16f77 +
74ls00 +
Custom firmware +
DScaler 4.1.15 +
Saleae Logic 1.0.21

An equation that = Joy.

Here's the trace of SPI activity whilst loading the above program from MMC. Click for a larger view. Go on. I know you want to.


That'll be ~5k of Galaxians loading in ... ooh let me see now...



Oh yes. 0.3 seconds.

The previous board sat cuddled up to the VIA and all of the SPI communication was performed by banging bits against one another. This board takes bytes at a time, like a man. These are then passed on to the inboard SPI hardware and the reply posted back.

Some PICs, like the one used here, have what's called a parallel slave port. You access it like any other bus-based device. It has /EN, /OE and /WR lines which directly control the state of one of its 8-bit data ports. With no valid control signals present the chip sits happily processing with the PS port data lines in a high impedance state. Enabling the chip and clocking /WR will latch the data found on the port at that time. Similarly asserting /OE with the chip enabled will take the port out of high impedance state and present latched data to the bus. There are separate latches for reading and writing. The reception and recovery of data can cause an interrupt. Very handy. Having been an AVR freak for a long time now since migrating away from PICs I'm starting to see their appeal once more. There. Ah sayed it. I Love PICs. Again. I don't know why I fell out of love with them, I suppose it was becasue they felt rough and ready. AVRs were sexier. With better development tools. I digress.

So with appropriate code written, and some neat decoding logic in place to translate the 6502's r/wr signal to separate /RD and /WR signals away we go. Fortunately I'm a reasonable programmer and the AtoMMC firmware that I wrote for the VIA interface was device independent. After as long as it took to recompile and burn a new EPROM, I had a new working driver for the new working hardware.

In all the round-trip time from presenting a byte to the chip to receiving a reply is as long as it takes to process the following 16 cycles:
;~~;~~;~~;~~;~~;~~;~~;~~;~~;~~;~~;~~;~~;~~;~~;~~;~~;~~;~~;~~;~~;~~;~~
;
; spi transfer
;
; on entry
; A = byte to transmit
;
; on exit
; A = received byte, Y preserved, X trashed
;
xferbyte:
sta $b400
nop
nop
nop
nop
lda $b400
rts


Quite a big difference from the original code..
;~~;~~;~~;~~;~~;~~;~~;~~;~~;~~;~~;~~;~~;~~;~~;~~;~~;~~;~~;~~;~~;~~;~~
;
; spi transfer
;
; on entry
; A = byte to transmit
;
; on exit
; A = received byte, Y preserved, X trashed
;
xferbyte:
stx XBTEMP
sty XBTEMP+1

ldy #8

xb_xferbit:
sta XBTEMP+2 ; ZP write .. faster than PHA

and #MOSI ; present data, CS is low
ora #CLK ; bring clock high
sta VIA

ldx VIA ; read data

eor #CLK ; bring clock low
sta VIA

txa ; rx'd data into carry
ror a

lda XBTEMP+2
rol a ; 7<-next bit, 0<-rx'd data

dey
bne xb_xferbit

ldy XBTEMP+1
ldx XBTEMP
rts

All this joy has happened relatively quickly since receiving my logic analyser. I don't know how I coped without it. Having a window onto the private world of your signals is more revealing than the televisual programme 'Katie and Peter'. Speaking of feeling dirty I must admit that I used to feel the idea of attaching a peripheral processor arguably more powerful than the host computer to be anathema. However now I'm over the initial revulsion I have to admit I quite like it. Again I digress. So for a perfect example of how having an analyser helps, let's look at the behaviour of the flip-flop that I programmed to change whenever a SPI transfer completes:



You might be able to see it in the thumbnail here, but click for more pixels. The top two signals are enable and write. Taking the falling edge of the write line, when data is latched from the bus and passed to the SPI hardware, we see that the third line, rdy, is flipped about 12 microseconds later indicating that data is ready for reading. The writes occur at about 16 microsecond intervals. Remember the 16 clock code earlier? Aah yes. That code was generating this trace. I could probably drop a couple of NOPs to push things a little faster but I want a small comfort zone. I could also use a faster SPI clock. I'll perhaps experiment with that another time.

Mmm. Katie and Peter. Dirty boy. Go to your basket.

Rapidly scribbled and then

No comments:

Contact Form

Name

Email *

Message *

This is how we do it

MMC (9) acorn atom (7) sord m5 (7) zx81 (7) multicart (6) arduino (5) Sord (4) tatung einstein (4) Atari 800 (3) Chuckie egg (3) M5 (3) M5Multi (3) c128 (3) sd card (3) sd2iec (3) sio2sd (3) 6502 (2) Max6956 (2) QL (2) RCM (2) assembler (2) avr (2) c64 (2) cadsoft eagle (2) eeprom (2) einSDein (2) mmbeeb (2) multi-cart (2) spi (2) system 80 (2) ufat2 (2) vic20 (2) video genie (2) 6502 second processor (1) 6522 (1) 8255 (1) Acorn BBC Micro (1) Apple 2e (1) Apple ][ 2 two (1) BBC 6502 second processor (1) BBC micro (1) DevicePrint (1) Double Choc Chip Muffins (1) FAT (1) IO (1) Jupiter Ace (1) LED (1) Master 128 (1) PCB (1) PIC (1) POV (1) PROGMEM (1) Pineapple (1) ST (1) Spectrum 128 (1) antex (1) arcade spinner (1) arduino shield (1) atari (1) atmel (1) bakewell tart (1) beer (1) bird's nest (1) bitbucket (1) brokenated XC special (1) cake (1) cassette (1) cassette interface (1) colecovision (1) compact flash (1) convert (1) dac (1) de-yellowing (1) dev cart (1) development tool (1) eaca (1) efficient (1) einsdein. z80 (1) esp32 (1) esp8266 (1) eye strain (1) failosophy (1) filesystem (1) finally (1) fram (1) french polishing (1) fuse (1) fuses (1) game development (1) games (1) gaming (1) github (1) glue (1) google chrome (1) heroic failure (1) high voltage programming (1) hot irons (1) if (1) jiffydos (1) joey beltram (1) lego robot (1) library (1) lying (1) machine code (1) matron (1) microcode (1) mmc interface (1) mmc2iec (1) mmm (1) mouse guts (1) oscilloscopes (1) pcm (1) pic32mx (1) porn (1) proto shield (1) purple (1) repo (1) retro computer museum (1) retro hard-on (1) rom box (1) sd (1) sd-x (1) sd2mmc (1) seadragon (1) silliness (1) small (1) software master (1) soldering (1) spi software master (1) stray capacitance (1) string (1) techadventure (1) test equipment porn (1) ts1000 (1) turtle cheesecake (1) tweaking (1) vc20 (1) video head (1) video ram replacement (1) weewee (1) wingasm (1) wire library (1) wodges of IO (1) xilinx cpld (1) yellowing (1) z80 (1) zx spectrum (1) zxpander (1)
Unless otherwise stated all of the original work presented here is:

Creative Commons License
Licensed under a Creative Commons Attribution-Noncommercial 2.5 Generic License.

The work of others where referenced will be attributed appropriately. If I've failed to do this please let me know.