Go Down

Topic: T0/T1 internal pull-ups (Read 412 times) previous topic - next topic

mkwired

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.

CrossRoads

Why? When the pins are outputs/clock sources, the 40mA drive capability will far outweigh the 0.25mA an pullup can offer.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

mkwired


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.

majenko

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...

mkwired


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.

majenko

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.

mkwired

It works!

Code: [Select]

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);
}

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy