Electronics > Microcontrollers

AVR Port settings when using an external Oscillator ?

(1/2) > >>

MathWizard:
I'm using an ATtiny44A, and I know to change to an EXT XTAL, I need to change the CKSEL fuse bits, and consider the SUT start-up times.

XTAL1 is the input pin, and XTAL2 is the output pin, but do I have to set that up in the DDR and PORT register's, or is that automatically done when changing to the EXT OSC source ? Can those DDR/PORT bits for XTAL1/2 still be changed afterwards, or is it locked, and it doesn't matter?

Sometimes, I might want to clear a whole 8-bit port register at once, and I'm just wondering if that could break the EXT OSC settings.

Kleinstein:
The DDR register settings should have not effect for the XTAL1 pin. It can have an effect for the XTAL2 output pint, that is normally not used with an external oscillator. The XTAL2 pin may be available as an extra IO pin, not just clock out.

MathWizard:
Well this is for the inverting amp between the XTAL1/2 pins, and the crystal is in the feedback path. But in the datasheet, I don't see any warning, or note saying what happens if you were to use OUT to send full byte in a REG, to the DDRB or PORTB in this case.

Of the other PortB pins, I'm only using 1 of them, so I shouldn't have to worry about those DDRB, PORTB bits. But in other chips, I may want to use OUT, and then would I set those bits to 0 or 1 ?

IDK, I'm about to solder up the crystal, so I'll try a little program and see what happens. I also want to see how long it takes the OSC to stabilize.

I had wanted to use a deep-sleep state, and wake-up in a few cycles like from the internal OSC. But to my dismay, if the EXT OSC it restarted, it takes at least 258cycles to wakeup, and then they recommend a stabilization time of mili-seconds.

PCB.Wiz:

--- Quote from: MathWizard on January 10, 2025, 07:17:50 pm ---IDK, I'm about to solder up the crystal, so I'll try a little program and see what happens. I also want to see how long it takes the OSC to stabilize.

I had wanted to use a deep-sleep state, and wake-up in a few cycles like from the internal OSC. But to my dismay, if the EXT OSC it restarted, it takes at least 258cycles to wakeup, and then they recommend a stabilization time of mili-seconds.

--- End quote ---
Yes, external crystals can take millisecond region times to start. Ceramic Resonators are somewhat faster, but less accurate.
eg'
https://www.murata.com/en-global/support/faqs/timingdevice/ceralock/char/cch0003

How accurate does your clock need to be ?

If you enable a CLKOUT to a pin, you can check the start times without disturbing the crystal nodes.

Kleinstein:
An external cystal and external oscillator are different things. If the fuses are set to external oscillator it would not work with just a crystal and the µC would be blocked until a clock is applied.
The external oscillator are those packages with 3 or 4 pins, that also need power.

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod