It's been a long ambition of mine to get a better understanding of electronics. I've now built a few things entirely of my own design, and they all seem to be working pretty well. The most recent was a mini-dashboard to talk to my Megasquirts and display various figures on a cheap LCD1602 display. I've written it up at: $10 Megasquirt Dashboard. Had it in mind to call it millitune in honour of the old megatune. Fortunately I resisted the urge.
A couple of things:
- I'd be interested in any comments or criticisms of the electronics. It is my own design and I'm just fumbling my way through. Perhaps there's a smarter way to do the power supply, or maybe there's some circuit protections I should add in case of component failure.
- The race condition described in the .. um .. 5th last paragraph might be of interest to the MS2 development audience. Possibly also to TunerStudio development. I'll go into a bit more detail here than the above link covered
Here is the pertinent bit of the boot ROM:
Code: Select all
3F:f800 18 0b 00 00 11 MOVB #0x00,0x0011 ; MMC1.INITRG
3F:f805 18 0b 39 00 10 MOVB #0x39,0x0010 ; MMC1.INITRM
3F:f80a 4f 1c 30 05 BRCLR 0x1c,#0x30,0xf813; MMC3.MEMSIZ0
3F:f80e 18 0b 09 00 12 MOVB #0x09,0x0012 ; MMC1.INITEE
3F:f813 87 CLRA
3F:f814 f6 f7 fe LDAB 0xf7fe
3F:f817 51 COMB
3F:f818 27 28 BEQ 0xf842
3F:f81a 1c 02 5c 20 BSET 0x025c,#0x20 ; PIM.PERP
3F:f81e 1c 02 4d 01 BSET 0x024d,#0x01 ; PIM.PPSS pull down Rx
3F:f822 1c 02 4c 01 BSET 0x024c,#0x01 ; PIM.PERS pull enable Rx
3F:f826 c7 CLRB
3F:f827 04 31 fd DBNE B,0xf827
3F:f82a f6 02 58 LDAB 0x0258 ; PIM.PTP
3F:f82d c5 20 BITB #0x20
3F:f82f 27 11 BEQ 0xf842
3F:f831 1f 02 48 01 0c BRCLR 0x0248,#0x01,0xf842; PIM.PTS monitor if Rx low
3F:f836 1d 02 4d 01 BCLR 0x024d,#0x01 ; PIM.PPSS
3F:f83a 1d 02 4c 01 BCLR 0x024c,#0x01 ; PIM.PERS
3F:f83e 05 fb ff bc JMP [0xffbc,PC]
;
; Monitor mode
I toyed with the idea of putting hardware delays of some sort on the MS so that I could ensure that the dash was asserting logic 1 before the MS booted. This seemed pretty klunky. What I have done instead is also pretty klunky. Dash just checks if it is receiving the monitor mode prompt (a 3-byte sequence ending with >) and, if it is, it sends an appropriate monitor-mode command to cause the MS to reset. The command string is A2,00,3C,01 -- which writes a 1 to 0x003C, the COPCTL register. This causes a reset in a couple of milliseconds. When it comes up, dash is waiting for it with the RS-232 in the right state. It might be that TunerStudio could do the same check and hack and avoid the problems some people have had. OTOH, if the problem is something chronic in their USB RS-232 adaptors, I guess the hack won't help.
But one thing really puzzles me. In the above code, PTS[0] is put into pull down mode and is then checked for logic low. Surely this means that, unless there's something plugged into the Rx line holding it high, the test is always going to find zero at the pin? So how do our Megasquirts ever manage to boot at all when there's nothing plugged in?
Obviously reality is that it works but I'd like to know how.
Have fun,
Rob.