First, you can't have an accurate PAUSEUS 20 with 4MHz using PAUSEUS. See PBP manual.
OR you could still use a Timer/Counter... or use few asm GOTO $+1 or NOP.
First, you can't have an accurate PAUSEUS 20 with 4MHz using PAUSEUS. See PBP manual.
OR you could still use a Timer/Counter... or use few asm GOTO $+1 or NOP.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Hi Brian,
I have not given your post its due consideration but a couple of things jump to mind.
a/ Don't use LCDOUT in a time critical loop. The fastest indicator is to set a LED ON when the target event occurs and off at another part of the code.
HIGH LED takes more time and code space than LED = 1 so make sure the relevant TRIS statement makes the LED pin an output then set LED = 1 instead of LCDOUT.
b/ The statements....
Findedge:
A = linein
..dothings..
if linein = A then Findedge
make a looping structure that keeps going until linein changes state. It does not care whether LineIn is high or low, it just looks for a change. The assumption is that linein changes and stays changed for longer than a loop time in order to be found. Adding extras like LCDOUT can trip you up badly with fast toggling inputs. There is a problem with this approach if the state of linein changes during the ever so small time it takes to execute the 'if linein = A then findedge' line. If that happens you will miss finding sync but this will only be once every thousand or so blocks. It can be fixed.
c/ I agree with mister-e and you really should be running a 20 MHz part at 20 MHz for anything that interacts with real world data communications.
d/ The FindBit routine must run flat out. 20 MHz will be better than 4 MHz although it does look like 4 MH4 would be barely fast enough. You cannot have any LCDOUT or pauses in it or the routine will only find the first bit and the rest of the mesage will fall on the floor during the pause 500 line.
You CANNOT have a pause 500 after finding sync or finding a one or zero. You must immediately gather in the full 48 or 64 bit data field and decode it. Any pauses where you show them will cause the code to immediately miss the following data bits.
e/ I suggest the FindSync: routine should look something like.....
FoundSync:
LED = 1 'Shows we have met the SYNC conditions
GetData:
for b = 0 to 5 ' get 6 message bytes - bytes 6 & 7 are sync - so skip
for a = 0 to 7 ' get 8 bits in each message byte
gosub findbit
c.0[a] = valu ' fill the 8 bits in the byte
' MAY need a tweak to get MSB/LSB sense correct
next a
msg[b] = c
LED = 0 ' turn the LED off after one character time - about 4 mSecs
next b
-or- shift the LED = 0 command to after the 'next b' and have the LED on for 6 character times which may be easier to see.
HTH
Brian
Bookmarks