发表于:2006-09-09 17:34:00
2楼
单片机同步
SYNC3150:
CLR RW ;定义89c52拥有令牌
JB HS, $ ;检测3150状态,1为忙,0为闲
MOV P0, #5AH ;89c52写操作,5A为CMD-RESYNC
CLR CS
SETB CS ; 3150读操作
JB HS, $ ;检测3150状态
MOV P0, #00H ;89c52写操作,00为EOM
SETB RW ;传递令牌给3150
JB HS, $ ;检测3150状态
CLR CS
SETB CS ;89c52读操作
MOV A, P0 ;把读到的数据给A
JB HS, $ ;检测3150状态
CJNE A, #07H, SYNC3150
;判断是否为07 CMD-ACKSYNC ,不是则重新同步
CLR RW ;传递令牌给89C52
RET
-------------------------------------------------------
network input char nvin=0;
IO_0 parallel slave s_bus;
#define data_size 10
char i=0;
typedef struct parallel_io_interface
{
unsigned int length;
unsigned int data[data_size];
}piofc;
far piofc p_in,p_out;
when(nv_update_occurs(nvin))
{
p_out.length=10;
for(i=0;i<10;i++)
{
p_out.data[i]=3;
}
io_out_request(s_bus);
}
when(io_out_ready(s_bus))
{
io_out(s_bus,&p_out);
}
when(io_in_ready(s_bus))
{
p_in.length=data_size;
io_in(s_bus,&p_in);
}