You may want to add a little verification check after the call to the pulses to make sure everything looks legit. Something like: are all 7 values between the values of 700-2300 (Choose the range depending on the actual range of values for your receiver ± fudge). If not Ignore the values. Also we may still need some minor editing of which channels are processed by each pass…
Other options to maybe try:
Use Basic to read in the RC inputs. If Zenta’s logic analyzer output was correct awhile ago. you could try:
pulsin 0, 0, val0
pulsin 2,0, ...
In the order 0,2,4,5,1,3,6
This will take on the order of 2-3 full RC passes to get the data. The hack I did earlier will take 2 passes…
Or write a new version of the RC input that handles overlapping IOs. Earlier I wrote a version in basic, that would probably need to be converted to assembly language to work fully. Also I would probably change the beginning of the function that waits for all of the IOs to be low before starting as this could waste most of a complete cycle. Would probably need to grab the start IO mask and ignore the transition to low for all IOs that were high at the start…
In case you are interested this was the outline of code I had awhile ago:
[code]awPulsesIn var word(7)
bPulseTimeout var byte
;=============================================================================
; this is just the outline of a function. Should convert to assembly language.
;==============================================================================
wLoopCntr var word ; how many times we went through the loop
bMask var byte ; Our mask of the bits we are still interested in
bIOVal var byte ; The IO port value (masked)
bIOValPrev var byte ; The previous IO port value (masked)
bIODif var byte ; what changed - What IO bits were turned off
abIOStates var byte(15) ; what state we were at
awIOTimes var word(15) ; Value of the loop counter.
cSaveStates var byte ; index into our saved array.
;=============================================================================
; this is just the outline of a function. Should convert to assembly language.
;==============================================================================
; like 2 but setup to use timerW instead of loop ctr
MPulseinV3:
; Make sure all 7 IOs are set to input.
PMR5 = 0 ; all IO lines are general IO
PCR5 = 0 ; All are input (may want to leave bit 7 alone…
bMask = 0x7f ; what we are still looking for...
; first wait until all of the IOs are low
while (PDR5 & bMask )
;
wend
; setup timerW
TCRW = 0x30 ; setup for clock/8
TMRW = 0x80 ; make sure it is running
TCNT = 0 ;
; initialize for our main loop
cSaveStates = 0 ; no saved states
bIOValPrev = 0x0 ; no bits were on.
; main loop - to be used as actual values all code paths through this loop would need
; to have a consistent timings...
while bMask and (cSaveStates < 15)
bIOVal = (PDR5 & bMask ) ; get the masked value
if bIOVal <> bIOValPrev then
abIOStates(cSaveStates) = bIOVal ; save away the new value
awIOTimes(cSaveStates) = TCNT ; save away the time from timerW
cSaveStates = cSaveStates + 1 ; increment how many states we have saved
; Turn Off any bits in our mask that were on that are now off...
bMask = bMask & ((!bIOValPrev) | bIOVal)
bIOValPrev = bIOVal ; remember the previous value
endif
wLoopCntr = wLoopCntr + 1 ; increment our loop counter
wend
; Now to post process the data
for wLoopCntr = 1 to cSaveStates-1
; Assumes that not two will end at the same time... Could handle this as well
bIOVal = abIOStates(wLoopCntr-1) & !(abIOStates(wLoopCntr)) ; I think should give us a mask of the bits that turned off
if bIOVal then
; reuse bMask
bMask = wLoopCntr-1
while (bMask > 0) and (abIOStates(bMask) & bIOVal) ; loop back to find out when this bit was turned on.
bMask = bMask - 1
wend
if !(abIOStates(bMask) & bIOVal) then
bMask = bMask + 1
endif
; figure out which bit...
bIOValPrev = 1
while ((bIOVal & 0x1) = 0)
bIOValPrev = bIOValPrev + 1
bIOVal = bIOVal >> 1
wend
awPulsesIn(bIOValPrev) = (awIOTimes(wLoopCntr) - awIOTimes(bMask)) / 2 ; End - start /2 as clock is /8
endif
next
; now print out masks and timers to see what is happening...
for wLoopCntr = 0 to cSaveStates-1
serout s_out, i9600, [hex abIOStates(wLoopCntr), ":", dec awIOTimes(wLoopCntr), " "]
if (wLoopCntr & 0x7) = 0x7 then
serout s_out, i9600, [13]
endif
next
serout s_out, i9600, [13]
return [/code]
Note: some of the stuff toward the end of this is debug stuff to see how it was working…
Kurt