cancel
Showing results for 
Search instead for 
Did you mean: 

Make 32bit timer by 2 16 bit timer

mkari
Associate III

Hi

I make a 32 bit timer by to 16 bit timer3(master) & timer4(slave)

Now I want my timer count antil 150000 (for example)

​How to get 150000 in two TIM3->ARR & TIM4->ARR register??

Does it have a special formula?

this number (150000) isn't ​fixed.

I have a lot of 32 bit different number that they sound set for my 32 bit timer (TIM3->ARR & TIM4->ARR). So I have to use a function that set TIM3->ARR & TIM4->ARR value Given different input numbers

Tanks​

10 REPLIES 10

Just factor the number in any arbitrary way, and don't forget, that the period is ARR+1; eg.

TIM3->ARR = 1000 - 1;

TIM4->ARR = 150 - 1;

Sometimes the particular usage requires that one of the timers has as high ARR as possible. For example, you'll find that reading the "current value" of such "32-bit" counter is tricky and you'll need to read master-slave-master and check if master did not roll over meantime; and to decrease the probability of rollover you'll want to minimize the slave's count frequency thus maximize master's ARR, i.e.

TIM3->ARR = 50000- 1;

TIM4->ARR = 3 - 1;

JW

Tanks

But this number isn't ​fixed.

I have a lot of 32 bit different number that they sound set for my 32 bit timer (TIM3->ARR & TIM4->ARR). So I have to use a function that set TIM3->ARR & TIM4->ARR value Given different input numbers

https://en.wikipedia.org/wiki/Integer_factorization

of which the simplest is https://en.wikipedia.org/wiki/Trial_division

etc.

You may be out of luck, if your number is prime, or if its largest factor is >65535.

JW

dbgarasiya
Senior II

you can use master-slave configuration

Piranha
Chief II

I'm guessing, but are you trying to implement software timers to trigger different actions after milliseconds, seconds, minutes, hours, days...? Those are typically done with SysTick or another single hardware timer, doing the rest of the job in software with a sorted linked list.

Hi

Thanks for the guidance

No, I need 3 32bit timer.

I used master slave configuration but my problem is arr value ​in mixed timer

Piranha
Chief II

Can you describe your intended use case of 32-bit timers in more details? What exactly will those do in your project?

dbgarasiya
Senior II

which controller you are using , in controller is there any 32 bit timer available or not ? first check

dbgarasiya
Senior II

.