Posted: Tue Jan 22, 2019 12:21 pm Post subject: Timeout for a bitwait
Hello all,
I've got a product that reads incoming serial messages from some 1980's hardware. Some users decided that they wanted to use longer cable lengths between my reader and the device, which is causing issues, because of the capacitance added by the additional cable length. This is causing clock pulses not to get read by my device. Right now, the routine that gets called is this:
Code:
programmerserialtransmit: If progstate <>1Then Set Nready
For Temp_b =1To8 Bitwait Nclk_in , Set'can't use shift out; with the READY construction 'Wait for rising clock
Data_out =Not progchannel.7
Bitwait Nclk_in , Reset If Temp_b =7Then Reset Nready
End If Shift Progchannel , Left , 1 Next End If Return
When the clock signal gets beaten down by the excessive cable length, my unit halts when it hits the first bitwait Nclk. I'm trying to figure out what the best way is to insert a "timeout" where if more than 10ms have elapsed, then it just exits the programmerserialtransmit label. Does anybody have experience with this sort of issue?
Create your own Bitwait and let it count up a variable while it waits, if the variable rolls over a certain limit (your 10ms), set a flag.
Use no delay within the count-up loop, simply use a variable big enough, the used up processor cycles will do your delay.
Include a check of the flag in every custom Bitwait and into the 1to8-loop.
Get rid of For/Next and use a Do/Loop or While/Wend, as you can include the flag as break condition there, don't forget to count up b yourself.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum