configuring 8052 not to use address lines

Thread Starter

testuserabcdef

Joined Jul 12, 2016
127
I have a circuit with an AT89S52 which is too complex to post, but what I did which does not seem to work is to create a case where P0.1 is an activate command pin which connects to the positive enable on the 74HC138, and Pins 2.0 through P2.2 are command selection pins. Each of those connect to pins 1, 2, and 3 of the same 74HC138. The outputs are connected to clock pins of various devices except that one pin is directly connected to an LED.

The odd thing is the LED lights up and turns off several times even though I never used the LED address. This makes me think the 8052 is converting the P0 and P2 lines to address lines, yet my program never requests code outside of the internal code space, nor does it request data from external memory. Also, I have vpp/EA of the microcontroller set to 5VDC. When I tested the same microcontroller on a test board in which P2 and P0 are connected to LED's through pull-up resistors, the output is correct, so I know my code is executing, but I feel somehow the 8052 cheats and converts P0 and P2 to address lines without my knowledge.

Is there a way I can prevent the 8052 (specifically AT89S52) from turning P0 and P2 to address lines, yet still have the ALE continue to pulse?
 

Papabravo

Joined Feb 24, 2006
22,083
I have a circuit with an AT89S52 which is too complex to post, but what I did which does not seem to work is to create a case where P0.1 is an activate command pin which connects to the positive enable on the 74HC138, and Pins 2.0 through P2.2 are command selection pins. Each of those connect to pins 1, 2, and 3 of the same 74HC138. The outputs are connected to clock pins of various devices except that one pin is directly connected to an LED.

The odd thing is the LED lights up and turns off several times even though I never used the LED address. This makes me think the 8052 is converting the P0 and P2 lines to address lines, yet my program never requests code outside of the internal code space, nor does it request data from external memory. Also, I have vpp/EA of the microcontroller set to 5VDC. When I tested the same microcontroller on a test board in which P2 and P0 are connected to LED's through pull-up resistors, the output is correct, so I know my code is executing, but I feel somehow the 8052 cheats and converts P0 and P2 to address lines without my knowledge.

Is there a way I can prevent the 8052 (specifically AT89S52) from turning P0 and P2 to address lines, yet still have the ALE continue to pulse?
ALE is on all the time by default, and it has to be specifically disabled. P2 is only the high order address for an external code or data memory access using the Data Pointer. P0 is only used for address and data on external code external data fetches. I guess you better send me a schematic.
 

Papabravo

Joined Feb 24, 2006
22,083
So you should see ALE beating up and down at about 3.33 MHz = 20/6
P0.1 has an external pullup because it is normally an open drain output. It will only be low to disable the decoder when you write a 0 to bit 1 of the Port 0 data register. Otherwise the decoder is enabled all the time and one of the eight outputs will be low ALL the time.
I don't see an LED anywhere on this schematic. It has to be complete if it is to be useful.
 
Last edited:

Thread Starter

testuserabcdef

Joined Jul 12, 2016
127
My project contains two data lines so I update them all at once. Do I need to add special code specific to at89s52 to prevent it from turning P0 and P2 into address lines? and I did add that pull-up to P0 because it has no internal resistors like P2 has.

Code:
LCDDAT EQU P1.1 ;LCD Data line
EXEC EQU P0.1 ;EXECUTE FUNCTION 1=exec
DAT EQU P0.4 ;Data for all functions except LCD
CLKRESET EQU P0.5 ;Reset on-board clock
FUNCSEL EQU P2 ;Function select: 0h - 7h

mov P3,#03Fh
mov P1,#0AFh
mov P0,#0h
mov P2,#0h
setb CLKRESET
nop
clr EXEC
nop
clr CLKRESET
;debugger

;force logic low in all shift registers (works)
mov R4,#10h
clrsr:
mov R5,#40h
clrsr2:
mov A,R4
dec A
mov R6,A
clr A
lcall Fexec
djnz R5,clrsr2
djnz R4,clrsr

;config one set of shift registers
mov R6,#0h
mov A,#082h
lcall Fexec
mov R6,#0h
mov A,#082h
lcall Fexec
mov R6,#0h
mov A,#0C0h
lcall Fexec

;config another set of shift registers
mov R6,#4h
mov A,#082h
lcall Fexec
mov R6,#4h
mov A,#082h
lcall Fexec
mov R6,#4h
mov A,#0C0h
lcall Fexec

;config even another set of registers
mov R6,#1h
mov A,#11h
lcall Fexec


;config one more set of registers
mov R6,#6h
mov A,#24h
lcall Fexec
;prepare for halt
mov P0,#0h ;this part executes fine
mov P2,#0F0h 
sjmp $
nop
nop
Fexec:
mov FUNCSEL,R6
mov R7,#8h
clr C
loop:
rlc A
mov DAT,C
mov LCDDAT,C
mov R2,#10h
djnz R2,$
cpl EXEC
mov R2,#20h
djnz R2,$
cpl EXEC
mov R2,#20h
djnz R2,$
djnz R7,loop
ret
END
 

ScottWang

Joined Aug 23, 2012
7,501
Why don't you just do some changes as:
1. Disconnects the P0.1_AD1(Pin 36) from 10K and Pin 6(G1) of ic2(74HC138).
2. Remove the 10K from circuit.
3. Connects the Pin 6(G1) of ic2(74HC138) to Vcc.
4. Disconnects the Pin 4(G2A), Pin 5(G2B) of ic2(74HC138) from Gnd.
5. Connects the Pin 4(G2A), Pin 5(G2B) of ic2(74HC138) to P2.3_A11(Pin 21).

If you do that then when you send x8H to the A,B,C of ic2(74HC138), the output of ic2(74HC138) will be disable, when you send x0H~x7H to the A,B,C of ic2(74HC138), the output of ic2(74HC138) will be enable.

x0H~x7H - the x beans that the High nibble(P2.4~P.2.7) of port 2 .

89S52circuit_Modified_testuserabcdef-ScottWang.gif
 

Thread Starter

testuserabcdef

Joined Jul 12, 2016
127
The problem is all my other gpio lines are in use and I configured mine so that my circuit board contains the fewest wire jumpers. Is there something special I need to do, even to the serial programming procedure? I mean I erased the chip, verified that it's erased, I put data on it, and I could read data back, I changed my reset circuit so instead of 2.2nF and 47nF capacitor, I used 2.2uF capacitor.

The only thing I'm thinking that might be an issue is the 47k (with 5% tolerance) in the reset circuit because the datasheet specific to my chip specifies that I should use 50k to 300k for a resistor.

I'm considering raising that resistor value, but is there anything else I can do to fix my problem without rewiring pins?
 

Thread Starter

testuserabcdef

Joined Jul 12, 2016
127
Wait a second...

so you're telling me I should use a resistor value 5x lower than the minimum requested by the datasheet along with a large capacitor?

The largest capacitor I have on hand is 4.7uF.
I guess I better make a long journey to the store again.

I'm curious, How is it possible that smaller resistor values work better?
 

cmartinez

Joined Jan 17, 2007
8,768
Wait a second...

so you're telling me I should use a resistor value 5x lower than the minimum requested by the datasheet along with a large capacitor?

The largest capacitor I have on hand is 4.7uF.
I guess I better make a long journey to the store again.

I'm curious, How is it possible that smaller resistor values work better?
This is the standard, old-school reset circuit for a 8051

8051-reset-circuit.jpg
My bad, the AT89S8252 datasheet recommends a resistor range of between 50K and 300K. My suggestion is that you keep the resistor that you've been using, but change the capacitor to 22µF to increase the amount of time that the reset pin is held high during startup.
 

Thread Starter

testuserabcdef

Joined Jul 12, 2016
127
My chip is at89s52, not at89s8252.

Now I'm confused. One says use 10K resistor and another says keep the resistor I'm using. and for capacitors, I don't have enough room for two caps in uF range because I'm fitting the caps inside the socket holder so my design can be compact.
 

Thread Starter

testuserabcdef

Joined Jul 12, 2016
127
I used to have startup problems when I first began using the 8052, so what I did was use the same recommended resistor (8.7k) and a larger capacitor (22µF) for the startup-reset circuit. That took care of most of my headaches.
cmartinez, what brand and chip number was your 8052 when you got it to work?
 

Thread Starter

testuserabcdef

Joined Jul 12, 2016
127
Now I just tried connecting a 100uF capacitor in parallel with the one already in my reset circuit, and the only thing different was the reset took longer to complete, yet the problem still remains.
 

ScottWang

Joined Aug 23, 2012
7,501
I was used AT89S52 and the R=8.2K, C = 10uF for the reset.
I want you to used two 4.7uF in parallel just want you to try, if it works then you can buy the 10uF to use.
 

cmartinez

Joined Jan 17, 2007
8,768
Now I just tried connecting a 100uF capacitor in parallel with the one already in my reset circuit, and the only thing different was the reset took longer to complete, yet the problem still remains.
Then we're dealing with an entirely different animal here...
You're gonna have to test your code on a line by line basis
 

cmartinez

Joined Jan 17, 2007
8,768
Have you tried using pull-up resistors on the MCU's pins? It's possible that somehow too much current is being demanded from the chip, and it's behaving strangely because of that.
A good value for that would be 4.7k
 
Top