Counter at the Tn Pin, can't figure out how it works

Go To Last Post
10 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Im trying to make an frecuencymeter and I need to detect an edge to define the period and then the frecuency.

Im working with STK600 + Atmega2560, I been reading the datasheet to figure out how to do this.

One of the things I need is to use one of the timers as a counter of external inputs (in my case the rising edges). In the datasheet they said how to configure the timer to use an external clock and how to make it count on the low or high state, and even on an edge, they said that it can be done, and it will use the Tn pin as the input.

The thing is that I dont know which is the Tn Pin.

How can I set it up, or to what port I should be looking at.

Sorry for my poor english.

Thanks for you time!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

T0, T1, etc are surely show on the chip pin out on page 2 of the datasheet .

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For the timer that has the T1 pin, go to that timer chapter in the specification sheet; Go to the register descriptions at the end of that chapter. There, you will see a listing of what each bit in each register does. Surely you will find some bits that control how that external clock input behaves.

There may also be a separate chapter on Clock Sources and Prescalers. Check there if you don't find the information at the end of the timer chapter.

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ka7ehk wrote:
For the timer that has the T1 pin, go to that timer chapter in the specification sheet; Go to the register descriptions at the end of that chapter. There, you will see a listing of what each bit in each register does. Surely you will find some bits that control how that external clock input behaves.

There may also be a separate chapter on Clock Sources and Prescalers. Check there if you don't find the information at the end of the timer chapter.

Jim

Wow! you really memorized the datasheets, I found the information about the registers I need to change in order to work as I want, my problem was that they always said "using the Tn pin" so I had no idea.

And thanks to Clawson now I know that in the early page 2 they have a diagram of the pins and there's many called T0 ... T5.

Now I guess that each one of those pins correspons to the timer/counter with the seam number?

Finally I gonna start writing code. just that little question to be sure what I'm doing.

thanks to both of your time and quick answers!!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Atmel tend to use notations such as PORTn to refer to a generic register that has several instances. It is up to you to substitute the correct number instead of "n".

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ka7ehk wrote:
Atmel tend to use notations such as PORTn to refer to a generic register that has several instances. It is up to you to substitute the correct number instead of "n".

Jim

Thanks Jim! then Im correct about that the T1 corresponds to the one that will be used in case Im using Timer1 ... Correct?

thanks for the time you've spend.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Check the block diagram for the counter. I think you are correct but not absolutely true.

By the way, none of us have "memorized " the specification sheets. All of the ATmega and ATtiny spec sheets have the same format and follow the same rules.

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ka7ehk wrote:
Check the block diagram for the counter. I think you are correct but not absolutely true.

By the way, none of us have "memorized " the specification sheets. All of the ATmega and ATtiny spec sheets have the same format and follow the same rules.

Jim

Well after some hours coding I have some idea of what Im doing thanks for the help you provided!

And now I can see that the structure of the datasheet is not that complex, thanks again!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Thanks Jim! then Im correct about that the T1 corresponds to the one that will be used in case Im using Timer1 ... Correct?


It might be that on a single timer you can select multiple outputs. You should be able to find if this is possible by checking the datasheet in the explanation section, or if you look in registers description. There it could have a table that states what bits select what input pins.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

meslomp wrote:
Quote:

Thanks Jim! then Im correct about that the T1 corresponds to the one that will be used in case Im using Timer1 ... Correct?


It might be that on a single timer you can select multiple outputs. You should be able to find if this is possible by checking the datasheet in the explanation section, or if you look in registers description. There it could have a table that states what bits select what input pins.

Yes, I can do it all in the seam counter.. using the overflow and the event capture on rising edge interrupts.

I'm trying to get my 2x16 LCD to work now.. so newbie, a lot to learn!

Thanks for all the help.