hexagon5un / AVR-Programming

Code examples for the book "Make: AVR Programming"
http://littlehacks.org/AVR-Programming
MIT License
725 stars 340 forks source link

avr 328p, crystal and leds #52

Open sjomae opened 9 months ago

sjomae commented 9 months ago

If a crystal is used, this does make DDRB unusable for using it for the LEDs, as in the book? Or is there a trick to make it work? The crystal is covering up the PB6 and PB7 pins.

Related: https://github.com/hexagon5un/AVR-Programming/issues/24

hexagon5un commented 9 months ago

Hi,

Yes it does -- those two pins are dedicated to the crystal oscillator amplifier internally, so if you use a crystal you can't use them as GPIOs.

For learning, I thought it was useful to have a full 8-bit block of GPIOs available. It makes the whole "write to a register, and corresponding LEDs light up" much more intuitive.

But when you need more speed, you can get it by using those two pins for a crystal.