pin use with crystal attached?

I am playing with a ATTiny841 and I want to run it at 16MHz. If I attach a crystal across pins 0 & 1 as specified can the pins be used for anything else?

No, if you're using those pins for a crystal, you can't have anything else connected to them.

Ok thanks. Can you disconnect it using transistors? Is there any other way to get a higher frequency? 2 pins is a lot to lose for my project.

Even if you could disconnect it with transistors, the moment you did so, the chip would stop running, because it would no longer have a clock (put another way, it would be running at 0 mhz, and not doing anything). The crystal (or whatever clock source) needs to be continually connected in order for the chip to work.

You could configure the chip for an external clock source, and use an external oscillator (ie, crystal + drive circuit), and configure the fuses for external clock instead of external crystal (note - this isn't supported directly by ATTinyCore, though you could set the fuses manually, and then program it like it had a 16mhz crystal) - that would only take one pin instead of two, but you'd need an external clock source. (There are a few ATTiny's that do let you run at 16mhz off the internal oscillator, namely the ones that have the on-chip PLL for high speed PWM - the Tiny x61 series and the Tiny x5 series - but neither of those have a UART or the other great features off the x41 series)

Or you could use a part with more pins on it (unfortunately, the insanely great feature set of the 841 is hard to match; I definitely have one being used in an application where I couldn't replace it with any other AVR micro short of a full on atmega x4 series, with like 3x as many pins, four times the flash and a much larger price tag)

Or you could run your project at 8mhz off the internal oscillator; most AVR projects aren't limited by the compute performance, so I'm surprised to hear that running at 8mhz is an issue. I generally run off a crystal whenever I don't need the pins (or BOM cost savings) in order to maximize the accuracy of the system clock.

Finally, there's always the option of port expanders or shift registers.

Thanks. I have not read in detail about how crystals work. I thought I did read that they were only used when the chip starts up, but I think that must have a been for calibration. I'd like to do 8-bit digital audio out, on the ATTiny85 I used the 64MHz pll clock to give a 250kHz pwm frequency. But I just tried the max I could arrange on the 841 which came to 31kHz and it didn't sound too bad. I also hope to use SPI and neopixels, do you know if these should work without a crystal? The 841 is attractive, especially since you incorporated master 'soft I2C' into Wire. Thanks for the port expander idea I may do that.

Finally, there’s always the option of port expanders or shift registers.

Or a chip with more pins.

The tiny1634 is a good next step up, in terms of pins and uart. But it does t have as many timers for pwm and the usi and one of the uart1 pins conflict