nya
nya

Reputation: 33

How to implement a 32 bits counter based on 16 bits FTM counter?

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

Answers (1)

old_timer
old_timer

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

Related Questions