3
\$\begingroup\$

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?

\$\endgroup\$
  • \$\begingroup\$ Not enough information for an answer, but I am trying to do the same for another Megawin chip, and have found it's not as simple as expected. Documentation lacking. \$\endgroup\$ – Cybergibbons Jun 7 '12 at 7:23
  • \$\begingroup\$ @cybergibbons Were you able to read the existing program? Have you had any success with it? Is it a 8052 family chip or something unrelated? \$\endgroup\$ – mmccoo Jun 8 '12 at 5:01
4
\$\begingroup\$

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.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Thank you for taking the time to answer. It sounds like I may have some success if I remove the part, put it in a programmer and read the contents. Is it fair to say that 8051 parts are all read the same? I feel more comfortable with the software aspects than the hardware stuff. \$\endgroup\$ – mmccoo Jun 8 '12 at 4:36
  • \$\begingroup\$ @mmccoo - I think it's safe to presume you can select an 8051 on the programmer. \$\endgroup\$ – stevenvh Jun 8 '12 at 5:10
2
\$\begingroup\$

The datasheet says that it can be programmed via ISP (In System Programming) which means you should be able to reprogram it. Its code might be locked so that you are unable to read it but you can erase the chip and reprogram it.

Atmel make a chip that looks compatible - the AT89S52 it datasheet has plenty of information about programming the chip. Plus there are appnotes and plenty of third party info on ISP programming - the programming pins are marked MOSI MISO SS and SCK, the communication protocol is SPI

Atmel also make a chip that is 8051 pin compatible but runs a much more modern and powerful AVR core - the atmega162 it could probably be programmed by adapting the Arduino environment if you supplied the required hardware definitions - this is the chip i would use to replace your MPC89E52A but then i have no 8051/2 experience only Arduino experience.

also check out the usbasp hardware running avrdude software for programming the chip You can buy a USBASP for about $4 on ebay. Apparently you can also program 8051's with the USBASP

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ I'm not sure that the ATmega162 is pin-compatible with the 8051. I looked up the datasheet here and the ATmega has Vcc at pins 6 and 17 while the 8051 has GPIO at those locations and the ATmega has GND at pins 28 and 39 while the 8051 has GPIO at those locations (both on the QFPs). They're otherwise remarkably consistent; there was clearly an effort to make the footprints similar. The 8051 could be used in place of an ATmega, but (1) that would be sad and (2) I don't think that's the direction in which the OP wanted to make a substitution. \$\endgroup\$ – Kevin Vermeer Jun 7 '12 at 15:23
  • \$\begingroup\$ Thanks for the pointers. I'm still holding out hope that I won't need to replace the controller and that reprogramming is somehow supported. Good to know about the arduino type possibilities. \$\endgroup\$ – mmccoo Jun 8 '12 at 4:39
  • \$\begingroup\$ Apologies if i'm wrong about 8051 compatability, the website AVR Freaks has a database which states that the (8515)[avrfreaks.net/… is pin compatible with the 8051 and the (atmega162)[avrfreaks.net/… is pin compatible with the 8515 \$\endgroup\$ – pault Jun 16 '12 at 14:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.