View unanswered posts | View active topics It is currently Thu Mar 28, 2024 1:54 pm



Reply to topic  [ 11 posts ] 
 Replacing a 8051 with a 89C52 
Author Message

Joined: Tue Dec 11, 2012 3:41 am
Posts: 68
A while ago I made a little project with the 8051/8031, it was the classical combo of NMOS 8051 with external ram and rom.
It works perfectly fine, I've been using it ever since(its a clock/alarm clock) and I got the sdcc compiler working with code blocks
so I am able to write the code in C on a modern machine.
Recently I was looking into doing some other projects, and since the Chinese STC89C52 are super cheap I ordered some to poke with.
But when I try using it instead of the NMOS 8051 it does not work. If its pin compatible and code compatible what could be the issue?


Mon Jan 29, 2018 1:01 pm
Profile

Joined: Wed Jan 09, 2013 6:54 pm
Posts: 1780
Have you been able to find a datasheet for the exact chips you have? Is there any possibility you have counterfeits?


Mon Jan 29, 2018 5:37 pm
Profile

Joined: Tue Dec 11, 2012 3:41 am
Posts: 68
They could be, the datasheet is here:
http://www.stcmcudata.com/datasheet/STC89C52.pdf
It might be a bit hard to read it tho...

But is there any major reason a 89C52 would not work as a drop in replacement?


Tue Jan 30, 2018 11:24 am
Profile

Joined: Wed Jan 09, 2013 6:54 pm
Posts: 1780
Do you have any kind of logic analyser, even a $12 one, which could record the memory accesses at boot time?

I would guess there's some difference in how you set the machine up for boot, which isn't right - perhaps tying off some pins.

Or possibly your address decoding timing is such that it's not strictly in-spec, and it worked for one model and not for another.

Or maybe a fast modern part demands better power supply decoupling, something like that?


Tue Jan 30, 2018 11:49 am
Profile

Joined: Tue Dec 11, 2012 3:41 am
Posts: 68
BigEd wrote:
Do you have any kind of logic analyser, even a $12 one, which could record the memory accesses at boot time?

I don't have any, I have one I made as a little project but its in a unknown condition.
12$ one? Which one is that?

BigEd wrote:
I would guess there's some difference in how you set the machine up for boot, which isn't right - perhaps tying off some pins.

There is only that EA pin to set where to read rom from.

BigEd wrote:
Or possibly your address decoding timing is such that it's not strictly in-spec, and it worked for one model and not for another.

That is done in a GAL so its fast.

BigEd wrote:
Or maybe a fast modern part demands better power supply decoupling, something like that?

I used the 7805 with electrolytic caps and 100nF ceramic next to the mcu.
I wonder if the clock frequency and number of steps per instructions are the same, since the old nmos takes 12 steps for a instruction.


Tue Jan 30, 2018 12:41 pm
Profile

Joined: Wed Apr 24, 2013 9:40 pm
Posts: 213
Location: Huntsville, AL
Dajgoro:

Assuming that the power supply, reset, and nEA are properly set and the memory (internal/external) is correctly programmed, then I would suggest making sure that the lower 8-bits of the address be passed through a latch ('373) and not a register ('374).

The use of a register rather than a latch has been an issue I've run across with this processor family. It is possible to use a register only if the ROM/EPROM to which the address is being presented has a fast enough access time relative to the rising edge of nPSEN. Although unlikely, some memory devices have access times much faster than their stamped values. In which case, the processor will receive stable instructions and data from the EPROM before the sampling window of the rising edge of nPSEN.

When I've had this type of problem with the processor family in my distant past :) , I've constructed very simple program like here: jmp here, or 0xC3 0x00 0x00, and used it to ensure that the memory address and bidirectional bus transceivers where working properly. Since you've had this system working for a while, this step would appear to be unnecessary. Just a suggestion.

_________________
Michael A.


Tue Jan 30, 2018 2:08 pm
Profile

Joined: Wed Jan 09, 2013 6:54 pm
Posts: 1780
(Sorry, not quite $12, but only a little over £12:
"The postman has just delivered a £12.49 Cypress FX2LP development board which can be used as a 16-channel logic analyzer."
from this thread.)


Tue Jan 30, 2018 3:03 pm
Profile

Joined: Fri Aug 01, 2014 3:00 pm
Posts: 23
Can you set the new chip up on a breadboard and get it working there? Different brands have different configuration registers, so you might have to fiddle with them to get it in the right mode. I know the Maxim and Atmel 8051s I have used have quite a lot you can configure (pull up mode, push/pull mode, fast pull up drivers, open drain mode, etc) and the default mode may be somewhat different from your NMOS part. Can you program the flash long enough to see if any of those alternatives will work with your external memory? Definitely check the datasheet (does this seem right?: http://www.datasheet-pdf.com/PDF/STC89C ... ETC-620042)

A quick look at the datasheet shows that there is a 6T mode which should work twice as fast as old 12T mode where you need 12 clocks per machine cycle. If that is on by default, it could mean your memory has to keep up twice as fast if you're running at the same frequency. This is also something you should be able to configure if the chip needs to stretch out memory accesses. You might need to start from Flash, set some configurations, then jump to your external memory.

EDIT: Do you have external RAM in the system as well? From page 22 of the datasheet: "To access the external data memory, the EXTRAM bit should be set to 1."


Wed Jan 31, 2018 10:30 pm
Profile

Joined: Tue Dec 11, 2012 3:41 am
Posts: 68
I found I had ordered a AT89C51 so I tried using it, and it works no problem.
So the problem is either with the 89C52 or with STC.
I am using external ram, all of the peripheral IC are located there.
As for the memory speed, it should handle no problem if the speed doubled since I have GAL decoding and 70ns ram.
If the peripheral access was too slow I should at least see garbage data on the screen.
I also checked the latch, and I'm using a 74HC573.
It would be nice if I could get away without having to do any sort of programming other than the external program rom.
I will try to program the STC89C52 internal rom and see if I can get it to boot that way.
As for the compiler, I'm using SDCC which is a little bit different than Keil UV4.


Thu Feb 01, 2018 2:06 pm
Profile

Joined: Fri Aug 01, 2014 3:00 pm
Posts: 23
Quote:
It would be nice if I could get away without having to do any sort of programming other than the external program rom
It doesn't look like the AT89C51 needs to do anything special to use external memory. If I were you, I would try setting some of the STC89C52 registers like EXTRAM from external ROM. Could it be that the chip is reading the ROM properly but not writing or reading anything from external RAM?


Thu Feb 01, 2018 8:30 pm
Profile

Joined: Tue Dec 11, 2012 3:41 am
Posts: 68
Quote:
If I were you, I would try setting some of the STC89C52 registers like EXTRAM from external ROM.

Could be, I'll try setting that.


Fri Feb 02, 2018 9:46 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 11 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software