cancel
Showing results for
Did you mean:

Senior

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
8 REPLIES 8

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

Guru

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

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..

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.

uint8_t N[100];

N[0]= =(TIM1->CNT);

For (i=1;i<100;I++)

{.

N[i] = N[0]+i*3;

}

Best regards

II

Guru

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?

Guru

You can limit the count of the encoder by using TIM->ARR = 12 - 1; // Giving range 0 .. 11 [12 values]

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Senior

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

Guru

Okay, so dent = 17 + 3 * i; But how does that help you?