Go Down

Topic: The frequency slows down continously but takes time to spped up! (Read 1 time) previous topic - next topic

henrimontreal

Quote
Henri, what board and IDE are you using ?



I use Arduino Due and IDE is 1.5.2.


UKHeliBob

It would have been easier if you had said that in the first place.
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

stimmer

You need to reset the counter whenever you change the period. What can go wrong is, if you shorten the period, the counter might have already gone past the new period value, and then it won't trigger the interrupt until it has counted all the way to 0xFFFFFFFF, wrapped around to 0 and got to the new period value - which is why it takes a while to speed up.

The line REG_TC0_CCR0=0b101; restarts the counter. You need to put it just after REG_TC0_RC0 = incomingValue*1000000;

henrimontreal


You need to reset the counter whenever you change the period. What can go wrong is, if you shorten the period, the counter might have already gone past the new period value, and then it won't trigger the interrupt until it has counted all the way to 0xFFFFFFFF, wrapped around to 0 and got to the new period value - which is why it takes a while to speed up.

The line REG_TC0_CCR0=0b101; restarts the counter. You need to put it just after REG_TC0_RC0 = incomingValue*1000000;


Stimmer! You are awesome! The problem got solved! Special thank to you!  :)

Now, I have one more question and I wonder if you or anyone who reads this can kindly answer to it. As you can see here and the page 871 and 872 of Datasheet for Arduino Due (AT91SAM), there are some special pins to enable the Timer.

Here we use TC0 Channel 0 and pins 2 1nd 13.

I tried Pin 61 and 62 (For PA2 and PA3 for the AT91SAM ) and TC0 channel 1  to get another independent frequency. For example

instead of REG_TC0_SR0 I have used REG_TC0_SR1. But this approach seems doesn't work properly. Do I need to apply other changes?

Do you know how I can get a couple of unique and completely independent frequency out of this?

Thank you for your help.

Go Up