Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/10/06 05:01
Read: times


 
#115915 - I got bored...
Responding to: ???'s previous message
and decided to go through and try to figure out what this code does... too much guessing. I commented a few things and couldn't follow. This is what I started.
$MOD51
;**************************************************************
;**************************************************************
;**							     **
;**---------------INTELLIGENT UPS PROJECT--------------------**
;**		  Inverter Module Software		     **
;**************************************************************
;*************ADVISOR: Prof. Dr. Eyup AKPINAR******************
;**							     **  
;**-----------------------DESIGNERS--------------------------**
;**	    	        BATUHAN CELIK			     **
;**			FUAD SOLTANOV			     **
;**			 HASIM TURGUT			     **
;**************************************************************
;**							     **
;**------------MicroController Family:ATMEL80C51-------------**
;**							     **
;**************************************************************
;**************************************************************
;(((((((((((((((((((((((MAIN PROGRAM)))))))))))))))))))))))))))
;
	ORG	00H			;Reset Vector
	JMP	START			;Was AJMP START
;
;(((((((((((((((((INTERRUPT SUB-PROGRAM)))))))))))))))))))))))
;
	ORG	03H			;External Int0 Vector
	JMP	DECIDE			;Was ACALL DECIDE
;
;	RETI				;Not needed
;
	ORG	13H			;External Int1 Vector
	JMP	STOP			;Was LCALL STOP
;
;(((((((((((((((((((MAIN PROGRAM START)))))))))))))))))))))))))
;
START:  ANL	P1,#83H
	MOV	IE,#85H
	MOV	IP,#01H			;ZERO CROSS INT. PRIORTY HIGH
	MOV	TCON,#01H		;INT0-> MADE FALLING EDGE
	MOV	R1,#00H		
	MOV	R2,#00H
REPEAT: NOP				;Endless looP
	JMP	REPEAT			;Here
;
;(((((((((((((((((((PWM SIGNAL GENERATORS))))))))))))))))))))))
;
;<<<<<<<<<<<<<<<<<<<<<<POSITIVE CYCLE>>>>>>>>>>>>>>>>>>>>>>>>>>
;
	ORG	33H
	CLR	P1.4
	CLR	P1.2
	NOP
	NOP
	NOP
	NOP
	NOP				;THESE NOP COMMANDS USED FOR OUR
	NOP				;IPM MODULE RISING/FALLING TIME DELAYS
	NOP
	NOP
	NOP
	NOP
	NOP
	SETB	P1.5
	SETB	P1.3
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	CLR	P1.2		;This port already cleared from above
	CLR	P1.4		;This port already cleared from above
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	MOV	R3,#1BH		;Set up delay
FWAIT2:	NOP
	DJNZ	R3,FWAIT2	;Delay loop here
;
CONTROL1:
	JB	P1.0,GOON1
	CLR	P1.3
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	SETB	P1.2
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	AMP	CONTROL1
;
GOON1:
	CLR	P1.2
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	SETB	P1.3
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	JMP	CONTROL1
;
;>>>>>>>>>>>>>>>>>>>>>>>>>>>ALARM<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
;
	ORG	94H			;This is the address that STOP returns to
	MOV	IE,#00H
	JMP	REPEAT			;Was ACALL REPEAT
;
;<<<<<<<<<<<<<<<<<<<<<<NEGATIVE CYCLE>>>>>>>>>>>>>>>>>>>>>>>>>>>
;
	ORG	100H
	CLR	P1.5
	CLR	P1.3
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	SETB	P1.4
	SETB	P1.2
	NOP
	NOP	
	MOV	R3,#1BH			;Set up Delay
FWAIT1:	NOP
	DJNZ	R3,FWAIT1		;Delay loop here
;
AGAIN:	JB	P1.1,CONTROL2
	CLR	P1.2
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	SETB	P1.3
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	JMP	AGAIN
;
CONTROL2:
	SETB	P1.2
	NOP
	NOP
	CLR	P1.3
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	JMP AGAIN
;
;((((((((((((((((((((((((INTERRUPT PROGRAM))))))))))))))))))))))
;
SPECIFY:
	JNB	P1.0,YES1		;IF !INT0 THEN YES1
	JNB	P1.1,NO3		;IF !INT1 THEN NO3
	JMP	SPECIFY			;Loop Here ;Was AJMP SPECIFY
YES1:   JNB	P1.1,YES2		;IF !INT1 THEN YES2
NO2:	MOV	R2,#0FH			;IF INT1 THEN LOAD R2:R1 WITH 0FFFH
	MOV	R1,#0FFH
	RET				;RETURN
;
YES2:	JNB	P1.0,YES3		;HERE +VE OR -VE CYCLE OF 50HZ SIN IS BEING SPECIFIED
NO3:	MOV	R2,#0FFH		;IF !INT0 THEN YES3 ELSE LOAD R2:R1 WITH FFFFH
	MOV	R1,#0FFH
	RET				;RETURN
;
YES3:	JNB	P1.1,YES4		;IF !INT1 THEN YES4
	JMP	NO2			;ELSE NO2
YES4:	JMP	YES2			;GOTO YES2
;
;<<<<<<<<<<<<<<<<<<<<CYCLE BRANCHING>>>>>>>>>>>>>>>>>>>>>>>>>>>
;
CYCLE:	
	CJNE	R2,#0FH,NEG		;R2
	MOV	30H,#33H
	MOV	31H,#00H
	POP	DPH
	POP	DPL
	PUSH	30H	
	PUSH	31H
	MOV	R2,#0FFH
	RET
;
					;HERE I'm MANUPULATING THE STACK POINTER TO BRACH
					;THE MICROCNTROLLER +VE OR -VE CYCLE PWM GENERATIG PROGRAM 
NEG:	MOV	32H,#01H
	MOV	31H,#00H
	POP	DPH
	POP	DPL
	PUSH	32H
	PUSH	31H
	MOV	R2,#0FH
	RET
;
DECIDE:					;External INT0 Interrupt Vector
	CJNE	R1,#00H,SAYKIL
	CALL	SPECIFY			;Was ACALL SPECIFY
	RETI				;Was RET
;
SAYKIL:	CALL	CYCLE			;This was branched to by a JMP instruction
	RET				;Returns to ???
;
STOP:	ANL	P1,#43H			;Called By External INT1 Vector
	SETB	P1.6			;Set this port for some reason?
	POP	DPH			;POP the last return address
	POP	DPL
	MOV	33H,#94H		;Set the return address to 0094H
	MOV	34H,#00H
	PUSH	33H			;PUSH it on the stack
	PUSH	34H
	RETI				;and return to it
;
END


This in particular has problems

DECIDE:					;External INT0 Interrupt Vector
	CJNE	R1,#00H,SAYKIL
	CALL	SPECIFY			;Was ACALL SPECIFY
	RETI				;Was RET
;
SAYKIL:	CALL	CYCLE			;This was branched to by a JMP instruction
	RET                             ;Returns to ???



I'm not attacking you, but this code needs more comments as far as setting/clearing ports and the purpose. You need to define some rules for yourself for the RET/RETI so that you are consistent. There is not that much code, so I think you should re-think the task/solution. I spent an hour on it, and it's not my project! This code could probably be reduced to at least half of what it is now. Some inside information would probably help people understand what you are trying to do.

Jon


List of 58 messages in thread
TopicAuthorDate
I'm in trouble with my PWM software            01/01/70 00:00      
   Interrupts ?            01/01/70 00:00      
   Firstly I want to explain how my hardwar            01/01/70 00:00      
      89C52            01/01/70 00:00      
         use a uC with a PCA            01/01/70 00:00      
         wiggling with the stack pointer            01/01/70 00:00      
            I know that....            01/01/70 00:00      
               no you don't            01/01/70 00:00      
                  To: Erik            01/01/70 00:00      
                     My code            01/01/70 00:00      
                     I can't tell            01/01/70 00:00      
                        His Code            01/01/70 00:00      
                           Nicely formatted            01/01/70 00:00      
                           As Erik suggested            01/01/70 00:00      
                           not valuable            01/01/70 00:00      
                     Hard to understand            01/01/70 00:00      
            asking for?            01/01/70 00:00      
               Weird DNA....            01/01/70 00:00      
                  that does make a difference            01/01/70 00:00      
            Playing with The Stack Pointer            01/01/70 00:00      
               Thanks            01/01/70 00:00      
                  ORG 33H            01/01/70 00:00      
                  OK            01/01/70 00:00      
                  replying to what in the above refer to m            01/01/70 00:00      
                  Listen and learn            01/01/70 00:00      
                     excellent question            01/01/70 00:00      
                     I'm listening and learning            01/01/70 00:00      
                        Oops            01/01/70 00:00      
                        Rewrite !            01/01/70 00:00      
                           WRONG            01/01/70 00:00      
                        Basic methods & specific details            01/01/70 00:00      
   To:Neil            01/01/70 00:00      
      +ve&-ve            01/01/70 00:00      
         totally unnneded information            01/01/70 00:00      
            +ve            01/01/70 00:00      
               Me too            01/01/70 00:00      
               halfway            01/01/70 00:00      
                  Just like the first time I saw 3v3            01/01/70 00:00      
                     Mid 70's            01/01/70 00:00      
                        the reason            01/01/70 00:00      
               Yes - Very Well Established            01/01/70 00:00      
      the trouble is            01/01/70 00:00      
      Other calls            01/01/70 00:00      
   One thing for the future            01/01/70 00:00      
   I do not see the point            01/01/70 00:00      
   I got bored...            01/01/70 00:00      
      argh, so many nops            01/01/70 00:00      
         NOP            01/01/70 00:00      
            New version            01/01/70 00:00      
               Thanks Steve...and others            01/01/70 00:00      
                  NO            01/01/70 00:00      
                  I suggest you look at your own changes            01/01/70 00:00      
   His new code            01/01/70 00:00      
      very informative            01/01/70 00:00      
         Another happy customer            01/01/70 00:00      
            Young Double E?            01/01/70 00:00      
            finished            01/01/70 00:00      
               the one at which end of the body?            01/01/70 00:00      

Back to Subject List