Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] at89c2051 replace by at89s52

Status
Not open for further replies.

jaksongats

Member level 2
Joined
Sep 7, 2010
Messages
44
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,526
hi frnds . i have an program of at89c2051 but i want to use at89s52 ..... can i use the program of at89c2051 in at89s52 uc
 

I think no as the controller 2051 is 20 pin controller and the other is 40 pin... they are not pin compatible and differ from each other as S52 offers more functionality... as the pins are different it cannot be used without modifications.......
 

2051 cannot be replaced by 8952 , chipwise.

but you can rewrite the program written for 2051 in 8952 , with modification required.
 

I think there is no need for that, you can burn the same hex in s52 and it will run
unless you are using internal comparator which is not available in s52.
 

hi frnds . i have an program of at89c2051 but i want to use at89s52 ..... can i use the program of at89c2051 in at89s52 uc

YES you can, Just remember to tie EA high on the 89s52. Now if you were going the other way, 89s52 - 89c2051 and the pins that were being used were port 0 or port 2, or any other pin that is not present in the 89c2051, the code would have to be modified.

you can try the code, if it does not work, post the code here, someone will help you.
 
Last edited:

ctownsend wrote:

....or any other pin that is not present in the 89c2051, the code would have to be modified.

that is what said earlier.
 

here is the code........
 

Attachments

  • asd.txt
    5.3 KB · Views: 52

This should work. Look at the comments in the code.

You will have to change whatever is connected to P0, to P1. You will probably need pullups on P1.0 and P1.1 (look at the datasheet)

There is no P3.6 on the 89C2051.

When using tables, you should use the labels rather than the addresses. This makes it easier when you change the code.

I changed it. The code takes up far less space the way it is now. Try it, post here if there are any problems.

Good Luck

Code:
ORG 000H
	AJMP MAIN
  
;EXT0 interrupt             	;these vectors should be in order or the file won't assemble
ORG 0003H
	ACALL INTERR1
	RETI
       
;T0 interrupt                  
ORG 000BH				;these vectors should be in order or the file won't assemble
	ACALL INTERR
	MOV P3,#0FFH		;please be aware that there is no P3.6 on the 89C2051!
	RETI
                                                   
;Main Function
;ORG 0100H
MAIN: 
	MOV IE,#83H
	MOV IP,01H
	MOV TMOD,#12H
	MOV TH0,#00H
	MOV TL0,#00H
	SETB IT0
;*************************
;*************************
;*************************
;	MOV P0,#0FFH		;there is no P0 on 89C2051
	MOV P1,#0FFH		;change this in your circuit
;*************************
;*************************
;*************************
	SETB TR0
	MOV R3,#00H
	MOV R2,#01H
	ACALL RAMC
	MOV TH1,#00H
	MOV TL1,#00H
	SETB TR1

HERE:
	AJMP HERE
;*****************************************************************              
INTERR:    ;T0 interrupt
	CJNE R6,#0FFH,SK
	MOV R6,#00H
	ACALL DISP
	SJMP SK1
SK: 
	MOV R6,#0FFH
SK1: 
	CLR TF0
	RET				
;*****************************************************************                          
; EXT0 interruupt
INTERR1: 
	CLR TR1
	CLR TR0
	MOV A,TH1
	MOV R1,A
	MOV A,TL1
	MOV R0,A 
	MOV R3,#00H
	MOV R2,#160
	ACALL DIV16_16
	MOV A,R2
	SUBB A,0FFH
	MOV TH0,A
	MOV TL0,A
	MOV TH1,#00H
	MOV TL1,#00H
	SETB TR1
	SETB TR0
	MOV R0,#23H
	MOV R6,#00H
	RET
;***************************************************************** 
RAMC:     
	MOV DPTR,#MSG
	MOV R7,#30
	MOV R0,#40H
                            
LOOP1: 
	MOV A,R7
	SUBB A,#01H
	MOVC A,@A+DPTR
	MOV @R0,A
	DEC R0
	DJNZ R7,LOOP1
	RET
            
DISP:  
	CJNE R5,#5,CONTINUE
	MOV A,@R0
	CJNE A,#'[',SPACE
;***************************
;***************************
;***************************
;	MOV P0,#11111111B		;there is no P0 on 89C2051
	MOV P1,#11111111B		;change this in your circuit
	SJMP CONT

SPACE: 	
;	MOV P0,#11111110B		;there is no P0 on 89C2051
;	MOV P1,#11111110B		;change this in your circuit
;***************************
;***************************
;***************************
CONT: 
	INC R0
	MOV R5,#00H
	AJMP NEGLECT
CONTINUE: 		
	MOV A,@R0       ; moves ASCII from RAM to R0
	CLR C
	SUBB A,#30H     ;
	MOV B,#05       ; ASCII to Adress conversion
	MUL AB          ;
	MOV DPTR,#LOOKUP  ;use labels here rather than address
	ADD A,R5        ; Memory offset
	MOVC A,@A+DPTR
;***************************
;***************************
;***************************
;	MOV P0,A		;there is no P0 on 89C2051
	MOV P1,A		;change this in your circuit
;***************************
;***************************
;***************************
	INC R5
NEGLECT: 
	RET
;***************************************************************** 
;ORG 230H	;don't need this, use the labels instead
LOOKUP: 
DB 10000010B,01111100B,01111100B,01111100B,10000010B,11111110B,10111100B,00000000B,11111100B,11111110B,10111100B,01110010B,01110100B,01101100B,10011100B
DB 01111010B,01111100B,01011100B,00101100B,01110010B,11100110B,11010110B,10110110B,00000000B,11110110B,00001100B,01101100B,01101100B,01101100B,01110010B
DB 10000010B,01101100B,01101100B,01101100B,11110010B,00111100B,01111010B,01110110B,01101110B,00011110B,11100000B,00001100B,01101100B,00001100B,11100000B
DB 10011110B,01101100B,01101100B,01101100B,10000010B
                                      
;ORG 285H	;don't need this, use the labels instead
DB 10000000B,01101110B,01101110B,01101110B,10000000B,00000000B,01101100B,01101100B,10001100B,11110010B,10000010B,01111100B,01111100B,01111100B,01111100B
DB 01111100B,00000000B,01111100B,01111100B,10000010B,00000000B,01101100B,01101100B,01111100B,01111100B,00000000B,01101110B,01101110B,01111110B,01111110B
DB 00000000B,01111100B,01101100B,01101100B,01100000B,00000000B,11101110B,11101110B,11101110B,00000000B,11111110B,01111100B,00000000B,01111100B,11111110B
DB 11111010B,01111100B,00000010B,01111110B,11111110B,00000000B,11101110B,11010110B,10111010B,01111100B,00000000B,11111100B,11111100B,11111100B,11111100B
DB 00000000B,01111110B,11001110B,01111110B,00000000B,00000000B,10011110B,11101110B,11110010B,00000000B,00000000B,01111100B,01111100B,01111100B,00000000B
DB 00000000B,01101110B,01101110B,01101110B,10011110B,10000010B,01111100B,01110100B,01111000B,10000000B,00000000B,01101110B,01100110B,01101010B,10011100B
DB 10011000B,01101100B,01101100B,01101100B,10110010B,01111110B,01111110B,00000000B,01111110B,01111110B,00000000B,11111100B,11111100B,11111100B,00000000B
   
;*******************************************************************                     
;ORG 600H	;don't need this, use the labels instead
MSG: 
DB 'SUMIT OJHA',0
;*******************************************************************
DIV16_16: 
	CLR C       ;Clear carry initially
	MOV R4,#00H ;Clear R4 working variable initially
	MOV R5,#00H ;CLear R5 working variable initially
	MOV B,#00H  ;Clear B since B will count the number of left-shifted bits
DIV1: 
	INC B      ;Increment counter for each left shift
	MOV A,R2   ;Move the current divisor low byte into the accumulator
	RLC A      ;Shift low-byte left, rotate through carry to apply highest bit to high-byte
	MOV R2,A   ;Save the updated divisor low-byte
	MOV A,R3   ;Move the current divisor high byte into the accumulator
	RLC A      ;Shift high-byte left high, rotating in carry from low-byte
	MOV R3,A   ;Save the updated divisor high-byte
	JNC DIV1   ;Repeat until carry flag is set from high-byte
DIV2:         ;Shift right the divisor
	MOV A,R3   ;Move high-byte of divisor into accumulator
	RRC A      ;Rotate high-byte of divisor right and into carry
	MOV R3,A   ;Save updated value of high-byte of divisor
	MOV A,R2   ;Move low-byte of divisor into accumulator
	RRC A      ;Rotate low-byte of divisor right, with carry from high-byte
	MOV R2,A   ;Save updated value of low-byte of divisor
	CLR C      ;Clear carry, we don't need it anymore
	MOV 07H,R1 ;Make a safe copy of the dividend high-byte
	MOV 06H,R0 ;Make a safe copy of the dividend low-byte
	MOV A,R0   ;Move low-byte of dividend into accumulator
	SUBB A,R2  ;Dividend - shifted divisor = result bit (no factor, only 0 or 1)
	MOV R0,A   ;Save updated dividend 
	MOV A,R1   ;Move high-byte of dividend into accumulator
	SUBB A,R3  ;Subtract high-byte of divisor (all together 16-bit substraction)
	MOV R1,A   ;Save updated high-byte back in high-byte of divisor
	JNC DIV3   ;If carry flag is NOT set, result is 1
	MOV R1,07H ;Otherwise result is 0, save copy of divisor to undo subtraction
	MOV R0,06H
DIV3: 
	CPL C      ;Invert carry, so it can be directly copied into result
	MOV A,R4 
	RLC A      ;Shift carry flag into temporary result
	MOV R4,A   
	MOV A,R5
	RLC A
	MOV R5,A		
	DJNZ B,DIV2 ;Now count backwards and repeat until "B" is zero
	MOV R3,05H  ;Move result to R3/R2
	MOV R2,04H  ;Move result to R3/R2
	RET
;*******************************************************************
END

here is the assembled hex file:
Code:
:020000000111EC
:0300030011453272
:10000B00113775B0FF3275A8838501B875891275E4
:10001B008C00758A00D2887590FFD28C7B007A0198
:10002B00116B758D00758B00D28E0135BEFF067E70
:10003B0000117B80027EFFC28D22C28EC28CE58DA9
:10004B00F9E58BF87B007AA03143EA95FFF58CF547
:10005B008A758D00758B00D28ED28C78237E002210
:10006B009001387F1E7840EF940193F618DFF82249
:10007B00BD050EE6B45B057590FF8000087D0001A1
:10008B009CE6C3943075F005A490009D2D93F590DC
:10009B000D22827C7C7C82FEBC00FCFEBC72746CEC
:1000AB009C7A7C5C2C72E6D6B600F60C6C6C6C728F
:1000BB00826C6C6CF23C7A766E1EE00C6C0CE09EE3
:1000CB006C6C6C82806E6E6E80006C6C8CF2827CC1
:1000DB007C7C7C7C007C7C82006C6C7C7C006E6EFF
:1000EB007E7E007C6C6C6000EEEEEE00FE7C007C95
:1000FB00FEFA7C027EFE00EED6BA7C00FCFCFCFC19
:10010B00007ECE7E00009EEEF200007C7C7C000028
:10011B006E6E6E9E827C747880006E666A9C986CA4
:10012B006C6CB27E7E007E7E00FCFCFC0053554D59
:10013B004954204F4A484100C37C007D0075F000B4
:10014B0005F0EA33FAEB33FB50F6EB13FBEA13FA49
:10015B00C389078806E89AF8E99BF95004A907A810
:10016B0006B3EC33FCED33FDD5F0DFAB05AA04226F
:00000001FF
 

thanks for this .......i will try this code and reply the results...thanks a lot

---------- Post added at 23:46 ---------- Previous post was at 23:43 ----------

This is an code for propeller display by at89c2051 but i want to do same thing by using at89s52 .....
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top