Pages: [1]   Go Down
Author Topic: T0/T1 internal pull-ups  (Read 335 times)
0 Members and 1 Guest are viewing this topic.
USA
Offline Offline
Full Member
***
Karma: 0
Posts: 238
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is it possible to use the internal pull-ups on pins T0 and T1 while using them as clock sources?  If it matters, I'm using the ATmega328P chip.
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 538
Posts: 27089
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Why? When the pins are outputs/clock sources, the 40mA drive capability will far outweigh the 0.25mA an pullup can offer.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

USA
Offline Offline
Full Member
***
Karma: 0
Posts: 238
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Why? When the pins are outputs/clock sources, the 40mA drive capability will far outweigh the 0.25mA an pullup can offer.

I want to connect it to the collector of a transistor without having an external resistor.
Logged

UK
Offline Offline
Faraday Member
**
Karma: 99
Posts: 4153
Where is your SSCCE?!?!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Pull-ups are for *inputs*.  Clock sources are *outputs*.

And a base resistor connects between a pin and the base of a transistor.  A pullup connects between the pin and Vcc.  How that can replace a base resistor I'm not quite sure...
Logged

Get 10% off all 4D Systems TFT screens this month: use discount code MAJENKO10

USA
Offline Offline
Full Member
***
Karma: 0
Posts: 238
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Pull-ups are for *inputs*.  Clock sources are *outputs*.

I think there is some confusion...  T0 and T1 are inputs (see section 14.3.3 of the datasheet).  I probably should have said that I want to select them as the clock source. 

And a base resistor connects between a pin and the base of a transistor.  A pullup connects between the pin and Vcc.  How that can replace a base resistor I'm not quite sure...

I want T0 or T1 to be held high while the transistor is off and pulled low when the transistor is on.  The transistor in this case is a photo-interrupter.
Logged

UK
Offline Offline
Faraday Member
**
Karma: 99
Posts: 4153
Where is your SSCCE?!?!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ah, gotcha.  My bad.

The data sheet is strangely silent on the matter.  The pull-up is shown between the pin and the "logic", so it may work.

All I can suggest is "try it and see".  Set it as input, turn on the pull-up, configure the timer, see if it's still pulled up.
Logged

Get 10% off all 4D Systems TFT screens this month: use discount code MAJENKO10

USA
Offline Offline
Full Member
***
Karma: 0
Posts: 238
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It works!

Code:
void setup() {
  Serial.begin(9600);
  pinMode(5, INPUT_PULLUP);
  TCCR1A = 0;
  TIMSK1 = 0;
  TIFR1  = 0;
  TCCR1B = _BV(CS12)
         | _BV(CS11);
  TCNT1 = 0;
}

void loop() {
  Serial.println(TCNT1);
  delay(1000);
}
Logged

Pages: [1]   Go Up
Jump to: