2023-09-29 10:49 AM
Hi,
I am doing something fundamental and cannot get this thing running.
n =(TIM1->CNT);
z= n + 3;
for the first loop cycle 'z' is =3 This is as expected, But as soon as the CNT is increased by 1 the value of 'z' is 4 as shown
LOOP COUNT | COUNTER VALUES | VARIABLE WITH +3 OPERATION |
1 | 20 | 23 |
2 | 21 | 24 |
3 | 22 | 25 |
4 | 23 | 26 |
5 | 24 | 27 |
2023-09-29 11:00 AM
Hello @ZExpo.1
In the table you give, the difference between CNT and S is always 3. I don't see any problem.
Best regards.
II
2023-09-29 11:16 AM
You're not really explaining the problem very well. You're not showing any loops, and how they would relate to a counter in an independent timer.
The count will keep counting. The bus interactions in a load-store sense might take longer to execute than you expect.
Things like TIM3->CNT += 3; might actually make the counter go backward, or at least glitch/saw-tooth. Depends on the frequency and the number of cycles on the AHB/APB buses
2023-09-29 11:23 AM
Yes, I did a logical error here, If I am adding +3 to the counter variable then I will be getting +3, I want to Create a table like this-
The initial Counter Value Should be 20
Value 2 =23
Value 3 =26
value 4= 29
.....
So on
Here Counter is driver by a Rotary Encoder which will have a limited range of 12 Dents only.
2023-09-29 11:56 AM - edited 2023-09-29 11:56 AM
uint8_t N[100];
N[0]= =(TIM1->CNT);
For (i=1;i<100;I++)
{.
N[i] = N[0]+i*3;
}
Best regards
II
2023-09-29 02:19 PM
Creating a table isn't really specific to a timer and doesn't have a whole lot of use.
Why don't you take a step back tell us what you're trying to achieve? Why is this table needed?
2023-09-29 02:40 PM
You can limit the count of the encoder by using TIM->ARR = 12 - 1; // Giving range 0 .. 11 [12 values]
2023-09-30 12:13 AM - edited 2023-09-30 12:14 AM
I want to generate the following numbers using my rotary encoder
Encoder dent 1->20
Enoder Dent 2 -> 23
Encoder Dent 3 -> 26
.
.
.
.
.
.
.
.
.
.
.
Dent 12->53
2023-09-30 06:50 AM
Okay, so dent = 17 + 3 * i; But how does that help you?