13.07.2015 Views

[Instruction] Contents

[Instruction] Contents

[Instruction] Contents

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Advanced Function <strong>Instruction</strong>FUN 67 PCALLCALLFUN 67 PCALLLBL : The subroutine label name to be called.• When call control “EN”=1 or “EN↑” ( P instruction) changes from 0→1, PLC will call (perform) thesubroutine bear the same label name as the one being called. When execute the subroutine, the programwill execute continuous as normal program does but when the program encounter the RTS instruction thenthe flow of the program will return back to the address immediately after the CALL instruction.• All the subroutines must end with one “return fromsubroutine instruction RTS” instruction; otherwise itwill cause executing error or CPU shut down.Nevertheless, an RTS instruction can be shared bysubroutines (so called as multiple enteringsubroutines; even though the entry points aredifferent, they have a same returning path) asillustrated in the right diagram subroutine SUB1~3.SUB1+65LBL65LBLSUB1Program 166JMPSUB2SUB3• When main program called a subroutine, thesubroutine also can call the other subroutines (socalled the nested subroutines) for up to 5 levels atthe most (include the interrupt routine).SUB265LBLProgram 2SUB3SUB3Program 31X 2X 3X 4X 5XLBL SUB1 LBL SUB2 LBL SUB3 LBL SUB468RTSCALL SUB1CALL SUB2 CALL SUB3 CALL SUB4RTS RTS RTS RTSMain program areaSubroutine area• Interrupt service programs (HSC0I~HSC7I、PSO0I~PSO3I、X0+I~X15+I/INT0~INT15、X0−I~X15−I/INT0−~INT15−、HSTAI/ATMRI、1MSI/1MS、2MSI/2MS、3MSI/3MS、4MSI/4MS、5MSI/5MS、10MSI/10MS、50MSI/50MS、100MSI/100MS) are also a kind of subroutine. It is also placed in subprogram area. However, the calling of interrupt service program is triggered off by the signaling ofhardware to make the CPU perform the corresponding interrupt service program (which we called as thecalling of the interrupt service program). The interrupt service program can also call subroutine orinterrupted by other interrupts with higher priority. Since it is also a subroutine (which occupied one level),it can only call or interrupted by 4 levels of subroutine or interrupt service program. Please refer to RTIinstruction for explanation.7-50

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!