原来并口操作(按字节输出进行位操作)一直实现不了,郁闷中将所调用的sleep函数改成for空循环,偶尔还能写进去(PS7219LED驱动器)。我是按一次按钮刷新所有显示寄存器内容,但要改一次数据,得按N次才能把几位数据刷新过来。 请问,在两位输出中间一般要等待多久,用for空循环需要多少次,有什么好办法可以得出指令间的时间间隔? 下面DELPHI码,请各位帮忙斧正,谢谢! TDI $378.6 P27219-TDI TMS $378.1 PS7219-LOAD TCK $378.0 PS7219-TCK //延时过程; procedure Delay; var ii,q,y: integer; begin q:=1; for y := 1 to 10 do //y , ii 一般取多少 begin //才能保证脉冲宽度? for ii := 1 to 5000 do begin q:=q*1; q:=q div 1; end; end; end; //下面是输出一字执行 if bTms <> 0 then //TCK = 1 PortOut(portadd1,$43) else PortOut(portadd1,$41); Delay; if bTms <> 0 then //TMS = 1 begin for i := 16 downto 2 do begin if bVal <> 0 then //TDI = 1 begin iTckLow := $42; iTdiVal := $42; iTckHi := $43; end else begin //TDI = 0 iTckLow := $02; iTdiVal := $02; iTckHi := $03; end; PortOut(Port,iTdiVal); Delay; PortOut(Port,iTckHi); Delay; PortOut(Port,iTckLow); Delay; end; end else //TMS = 0 begin for i := 16 downto 2 do begin if bVal <> 0 then //TDI = 1 begin iTckLow := $40; iTdiVal := $40; iTckHi := $41; end else //TDI = 0 begin iTckLow := $00; iTdiVal := $00; iTckHi := $01; end; PortOut(Port,iTdiVal); Delay; PortOut(Port,iTckHi); Delay; PortOut(Port,iTckLow); Delay; end; end; if bVal[1] <> 0 then //TDI = 1 begin iTckLow := $42; iTdiVal := $42; iTckHi := $43; end else //TDI = 0 begin iTckLow := $02; iTdiVal := $02; iTckHi := $03; end; PortOut(Port,iTdiVal); Delay; PortOut(Port,iTckHi); Delay; PortOut(Port,iTckLow); Delay;
if bTms <> 0 then //TCK = 0 PortOut(portadd1,$42) else PortOut(portadd1,$40); Delay; Delay;
|