8x51's as 8x31's, and NOPping OTP PICs

A project log for Repurposing OTP/mask-ROM microcontrollers

Many microcontrollers with internal ROM can be configured to run from external ROM!

Eric HertzEric Hertz 12/04/2022 at 09:140 Comments

At my first electronics gig, a contractor was developing with 8052 drop-in-compatibles. There was a pile of 8752's, as I recall, with windows, continuously cycling through the UV eraser for a day or two every couple weeks. When the updates were finally worked-out on the prototype system, they burnt OTP 8052s for the actual systems, about twenty of them.

Sounds great, right?

Well, after a week or so of testing all the systems working in unison, of course we found some things that needed to be changed, called in the contractor, and went through it all again. At least a few times.

Thankfully, about midway through the process, eraseable 8952s became affordable in our smallish quantities, so we only "wasted" probably around fourty to sixty OTP 8x52s.

I remember a cardboard coffin filled with these things, thinking "what on earth can be done with them now?!"


Fast-forward a couple years and I met a buddy who was in a similar situation at his workplace; they had piles of "burnt" One-time-programmable PICs waiting for trash-pickup.

He came up with something I'd thought utterly ridiculous at the time.

Apparently, as I recall, the PICs he scavenged had NOP=0x00. And, being that 'unburnt' bits were 1, he discovered he could essentially wipe-out all the old code and write whatever he wanted in the previously-unused portions of ROM.

Wow, smart!

Oh, but he was ridiculously-smarter than just that.

Eventually he got to the point of seeing which pre-existing op-codes he could modify (by changing 1 bits to 0), so he could do things like modify already-burnt IRQ tables and use far more of the ROM than was previously left 'unburnt'/empty.

I really thought him insane, at the time. But, I mean... THAT'S A HACK.


Somehow I hadn't pieced-together that the same might-could've been done with our burnt OTP 8052s... (Is NOP 0x00?), but I/we had also moved-on to the 8052-pin-compatible AVRs at that point, and reflashing was no problem. (nevermind /in-system/ programming!!!)


Fast-forward again, I started getting into the idea of learning a little about other CPU/uC architectures: MIPS due to some hackery with an old cable-modem, then on to MIPS-core PIC32s... I also dabbled in x86 with #Improbable AVR -> 8088 substitution for PC/XT , albeit from a completely different direction...

Then, a couple years ago, I wound up in a situation where learning Z80 made sense, as I began #Vintage Z80 palmtop compy hackery (TI-86) ... 

Started discovering these things really are all quite a bit more similar than I'd previously expected. There seem to be "camps" of folk into specific architectures, so I guess I mistakenly thought them to be very different, conceptually.

I started digging through my boxes of old scavenged PCBs to see what *other* processors I could learn about, and, repurpose. Many Z80s, a handful of others like an 8085, An 8031... 

We're talking CPUs, here, not microcontrollers, because, well, who has time to learn not only a new architecture, but *also* a different programming technique for each one?

But then, when I stumbled on the 8031 I learned something incredible! The 8031, on that particular scavenged PCB, was accompanied (of course) by an EPROM... BUT, it wasn't a CPU, it was an MCU. Weird.

Then it got even weirder... The 8031 is, frankly, just an 8051 without an internal ROM. Wut?!

Nope, it got even weirder, in a good way...

Apparently "That Pin" that was always tied to some rail on our 8052s is tied to that rail for the sake of identifying whether you want your 8051/52 to act like an 8051/2 or... whether you want it /to use external ROM/, bypassing the internal one, essentially (if not /actually/) turning your 8051/52 into an 8031/2.


It basically means those 8051/8052 microcontrollers can be turned into 8-bit CPUs, with a few extra inbuilt peripherals.


And, apparently, the 8051/31 aren't the only ones...

Yahknow that weird microcontroller used for old keyboards, in old PCs? I think it's the 8048. Well, as-marked, it's a keyboard-controller. But, really, it's a OTP microcontroller, which just happens to have a pin tied to a voltage rail, which if tied to the other rail turns it into, as I recall, an 8035, which is basically a precursor to the 8031 (yes, backwards numbering). 

Which, basically makes a keyboard-controller an 8-bit CPU, with a few inbuilt peripherals.



I wonder how many others there are like this? Surely microcontroller users love their peripherals and GPIO, yeah? And, surely, they're intended, en masse, for dedicated applications, where the ability to switch from internal ROM to external seems uncommon... Who'd "waste" a pin for this?


So, as it turns out, it would seem this is the result of the Mask-Programmed uC era. Customers c/would e.g. prototype with an 8031 (or 8051 in 8031 mode) with external ROM. Then, when their code's ready for mass-production, they'd send their PROM chips to the manufacturer to be mask-programmed into the i.e. 8051's they'd use in the end-product.


But what that means for us is that many application-specific (or even buggy) mask/one-time programmed uCs floating around on old junk PCBs can actually be used like plain ol' 8-bit CPUs. (well, I've found 16/32bitters, too).

I dunno, I think it's interesting.

And it's not limited to just Intel... I've found 6502-cores, H8... I'm sure I threw out countless in the past, thinking them completely unreusable.


Personally, I'm contemplating a slew of "NOPulators" of many different architectures. That'd be easy-enough to do on their original boards with a few trace-cuts and SIP resistor-networks.

 (I already did this with the 8031 board, as I needed a simple square-wave of various frequencies for a quick experiment... just NOPulate it and tap off an address line)

From there, well, If I had the resources (and space) a single-stepping front-panel with switches and LEDs for each "scavenged architecture" would be quite groovy...

Instead, I might consider a single front-panel with the ability to select which processor. I dunno.

And, of course, there's also the possibility of actually doing something useful with them (besides the learning experience from "trainer boards"). Maybe only reasonable with things available in quantities, like a bunch of OTP 8052's I think are still in their coffin...