OPN #Data_DB //Open Data Block
M002: LAR1 P#DBX 0.0
SET //LET #Sort_done = TRUE
S #Sort_done
R #DONE
L #DB_length
L 1
-I
Loop: T #Count //FOR INDEX = Count TO DB_length
L D [AR1,P#0.0] //IF M(INDEX) > M(INDEX+1) THEN
L D [AR1,P#4.0]
<=R
JC M003
// change M(INDEX+1) for M(INDEX)
L D [AR1,P#0.0] //LET TEMP = M(INDEX)
T #Temp
L D [AR1,P#4.0] //LET M(INDEX) = M(INDEX+1)
T D [AR1,P#0.0]
L #Temp //LET M(INDEX+1) = TEMP
T D [AR1,P#4.0]
SET
R #Sort_done //LET #Sort_done = FALSE
M003: TAR1
L P#4.0 //NEXT INDEX
+D
LAR1
L #Count
LOOP Loop //End of sorting pass
AN #Sort_done //If sorting is not done
S #DONE
JC M002 //Jump Conditionally to M002
BE
SET
SAVE
CLR
A BR
= #AA
/////////////////////////////////////////////////////////////////////////////////////////////////////////
以上是FC2的程序,如果下OB121,CPU能启动起来,不下CPU就停,看了诊断,如下:
Event 2 of 120: Event ID 16# 4562
STOP caused by programming error (OB not loaded or not possible, or no FRB)
Breakpoint in user program: Cyclic program (OB1)
Priority class: 1
FC number: 2
Module address: 38
Previous operating mode: RUN
Requested operating mode: STOP (internal)
Internal error, Incoming event
04:32:34.081 PM 09/05/2012
程序块都下进仿真了。
如果下载了OB121,CPU能启动起来,诊断如下:
Event 2 of 120: Event ID 16# 2522
Area length error when reading
Global DB, double-word access, Access address: 32
FC number: 2
Module address: 34
Requested OB: Programming error OB (OB121)
Priority class: 1
Internal error, Incoming event
04:37:48.889 PM 09/05/2012
FC2并没有被执行,OB1中,FC2是虚线,如图
这个是老程序,自己分析了下,可能是FC2的程序问题,看了好长时间,也看不出问题在哪?麻烦大侠,斑竹帮忙看一下,谢谢了。


