Electronic – How to reprogram a Megawin MPC89E52A

8051microcontroller

I have a couple old gizmos that use the microcontroller Megawin MPC89E52A. I want to download the existing code, disassemble it, make my own changes and reprogram.

The datasheet seems pretty basic, but it does state that it's "fully compatible with industrial-standard 80C51 series microcontroller." The datasheet also states "8K bytes flash memory embedded for application program" which I believe means it can be reprogrammed based on the googling I've done so far.

There is a row of pins labeled R, T, I, G, and A which I traced to RXD, TXD, INT0, RESET, and EA. EA is described in the sheet as "EA must be kept at low to enable the device to fetch program code from external flash memory" which sounds promising.

I know nothing about 80C51 parts except that they are all over. I assume that there are lots of tools for them if I know where to look.

My questions:

  1. do I have any chance of success with this particular part?
  2. If I can't reprogram it, can I at least download the existing code and would it be difficult to find a pin-compatible replacement? it's a QFP-44
  3. Assuming that reprogramming is possible, are the pins mentioned above the correct ones for this?
  4. What software tools for programming?
  5. Finally, what kind of a programmer do I need? Hopefully something usb is available, but I can make parallel or serial work.

Perhaps the most important question: Where's the best place to look for info on this?

Best Answer

What's this patching of that gizmo worth to you? If you know nothing about 8051 it may be a long and difficult task. Disassembling the code will give you a listing of tens of pages where only the instructions are readable, at least for someone who knows 8051. Labels and variables are just hollow numbers, and of course it's not commented either. If the source was C instead of assembler it may even look more abstract.

The datasheet is not a great help re the programming. It mentions ISP (In System Programming) and IAP (In Application Programming), but the ISP procedure seems to include setting SFRs, so it looks like that's actually IAP as well.

ISP means that you have outside access to a microcontroller which is mounted on your product's PCB, to program it. Everything is controlled through external pins.

IAP also means programming the microcontroller inside your product, but here the microcontroller has to execute a software procedure to talk to the external programming equipment and program the Flash.

So the controller seems to need programming code to reprogram the device. It will probably use the UART for this, but the programming facility has to be programmed in the device in the first place, and most low-cost commercial devices are not made to be reprogrammed.

The datasheet doesn't say anything about programming the device on a programmer, but since it's 8051 compatible the programming may be compatible with that as well, and any legacy universal programmer may be able to program it.
You'll have to carefully remove it from the PCB, so that you can resolder it later.

Pault's AVR alternative may be a good idea. I've never used them to replace 8051's, so check the datasheet carefully, pin for pin. Pault mentions the ATMega162, and it seems the ATMega8515 is also 8051 pin-compatible. Note, however, that neither datasheets mentions anything about this.