Reputation: 33
Problem: The micro controller i am using only supports returning 16 bits encoder values, but for my application, i need to 32 bits. Question: Is there anyway to implement/have my own 32 bits counter to recount ticks based on returned 16 bits counter value?
Upvotes: 0
Views: 135
Reputation: 71566
most counters have a rollover mode our count to zero or count to all ones and reload. for each rollover/reload have a variable count.
Say you want to count to 8000000 = 0x7A1200. you could have the timer count to 256 and then count how many times that rolls over when you get to 0x7A12 rollovers you have counted to 8 million.
You have to do this such you dont miss any rollovers/reloads. for example you could count 0x7A12 per reload/rollover and then after 256 rollovers you have counted to 8 million. giving your code a much longer time period in which to see that there had been a reload/rollover.
Upvotes: 1