electromanj
12-12-2009, 08:06 AM
Hello to All!
I am have some trouble understanding exactly whats going on in this method. Any and all explanations would be helpful.
This is the PUB COUNT from the BS2_Functions Object.
PUB COUNT (Pin, Duration) : Value
{{
· Counts rising-edge pulses on Pin for Duration in mS
· Maximum count is around 30MHz
· Example Code:
··· x := BS2.count(5,100)··············· ' Measure count for 100 mSec
··· BS2.Debug_Dec(x)···················· ' DEBUG value
··· BS2.Debug_Char(13)·················· ' CR
}}
······ dira[PIN]~········································· ' Set as input
······ ctra := 0·········································· ' Clear any value in ctrb
·················································· ········ ' set up counter, pos edge trigger
······ ctra := (%01010 << 26 ) | (%001 << 23) | (0 << 9) | (PIN)·
······ frqa := 1·········································· ' 1 count/trigger
······ phsa := 0·········································· ' Clear phase - holds accumulated count
······ pause(duration)··································· · ' Allow to count for duration in mS
······ Value := phsa······································ ' Return total count
······ ctra := 0·········································· ' clear counter mode
The main question is what is going on in the
ctra:=(%01010<<26 | (%001<<23 | (0<<9)| (PIN)
Also the
pause (duration)
I assume the Value in Value := phsa·would be a predefined var and could be any·name.
Sorry about the cluttered post I don't know how to·post code with the white boxes and blue letters.
Thanks for any help!····
·
I am have some trouble understanding exactly whats going on in this method. Any and all explanations would be helpful.
This is the PUB COUNT from the BS2_Functions Object.
PUB COUNT (Pin, Duration) : Value
{{
· Counts rising-edge pulses on Pin for Duration in mS
· Maximum count is around 30MHz
· Example Code:
··· x := BS2.count(5,100)··············· ' Measure count for 100 mSec
··· BS2.Debug_Dec(x)···················· ' DEBUG value
··· BS2.Debug_Char(13)·················· ' CR
}}
······ dira[PIN]~········································· ' Set as input
······ ctra := 0·········································· ' Clear any value in ctrb
·················································· ········ ' set up counter, pos edge trigger
······ ctra := (%01010 << 26 ) | (%001 << 23) | (0 << 9) | (PIN)·
······ frqa := 1·········································· ' 1 count/trigger
······ phsa := 0·········································· ' Clear phase - holds accumulated count
······ pause(duration)··································· · ' Allow to count for duration in mS
······ Value := phsa······································ ' Return total count
······ ctra := 0·········································· ' clear counter mode
The main question is what is going on in the
ctra:=(%01010<<26 | (%001<<23 | (0<<9)| (PIN)
Also the
pause (duration)
I assume the Value in Value := phsa·would be a predefined var and could be any·name.
Sorry about the cluttered post I don't know how to·post code with the white boxes and blue letters.
Thanks for any help!····
·