OK - I have written a PicBasic routine to do mPULSIN - a bit slow as you would expect, but works
I have also written in assembler but need to test before posting....Code:for i = 0 to 7 : Period[i] = 0 : next pCount = 65535 ' PULSIN_MAX k = Mask cycle0: j = mPort & k 'Port AND Mask for i = 0 to 7 if (j & dcd i) = dcd i then 'Bit i set - Pulse found Period[i] = Period[i] + 1 else 'Pulse ended or no pulse if Period[i] >0 then 'Already received a pulse k = k & (~dcd i) 'Clear i'th bit in mask endif endif next if k = 0 then return pCount = pCount - 1 if pCount <> 0 then cycle0 return
Peter




Bookmarks