859
Chapter 41 Up/Down Counter
7.Q&A
7.11 How do I enable/disable Up/Down Counter's count operation?
Use the count activate bit (UDCS.CSTR).
• How do I start counting?
Timer mode Counting starts using the internal clock (See 7.3.)
Up/down count mode Counting starts when the edge of an AIN or BIN pin input signal is detected.
(See 7.4.)
Phase difference count mode Counting starts when a phase difference between AIN and BIN pins is
detected.
Note that the count operation enable level must be detected, before the ZIN pin's gate function can be
selected.
7.12 How do I know the previous count direction (the current rotation direction)?
Use the up/down flags (UDCS.UDF[1:0]).
This flag has nothing to do with interrupts. So, use the count direction change flag (UDCC.CDCF) for interrupt
processing.
7.13 How do I know count direction changes?
Use the count direction change flag (UDCC.CDCF).
7.14 How do I know that a compare-match has occurred?
Use the compare detection flag (UDCS.CMPF).
Regardless of counter operations (counting up/down, or a value being set or reloaded), the compare detection
flags are set to “1” when the count value agrees with the compare value.
When the count-up value agrees with the compare value: Count activate bits (UDCS.CSTR)
To disable Up/Down Counter's count operation Set the bit to “0”.
To enable Up/Down Counter's count operation
(To activate count operation)
Set the bit to “1”.
Up/down flag (UDF[1:0])
“00” indicates that no counting is performed after resetting.
“01” indicates that counting down is performed.
“10” indicates that counting up is performed.
“11” indicates that both counting up and down are performed, resulting in no change in the count value.
Count direction change flag (CDCF)
“0” indicates that no direction change has been made after clearing the flag.
“1” indicates that a direction change has been made once or more after clearing the flag.
Compare detection flag (CMPF)
“0” indicates that the Up/Down Counter's count value does not agree with the compare value.
“1” indicates that the Up/Down Counter's count value agrees with the compare value.