Download Moacon manual - Comfile Technology
Transcript
MOACON User’s Manual count u16 count (u8 cntChannel) cntChannel : Channel number (0 or 1 for DP-HCNT) returns the current value of the counter on channel, cntChannel. Reads the current value of the counter on channel, cntChannel. The counter counts independently of the processor, so while other parts of the program may be running, the counter is still counting. Calling count returns the current value in the counter. countMode(0,0); u16 cnt = count(0); // Set channel 0 to function as a basic counter // Read current count from channel 0 countMode(0,1); u16 cnt = count(0); // Set channel 0 to function as an encoder counter // Read current count from channel 0 If reading signed values is desired, the return value should be interpreted in 2's complement (-1 = 0xFFFF) and should be stored as a singed 16 bit integer ( short data type). 16 bit signed integers have a range of – 32,768 to 32,767. countMode(0,1); short cnt = count(0); // Set channel 0 to function as an encoder counter // Read current count from channel 0 (signed numbers) If you need to scale the counter to support higher count values, use the countPrescaler function. Comfile Technology MOACON – User's Manual 87 of 162