Pages: [1]   Go Down
Author Topic: Internal oscillator - needs time to settle?  (Read 823 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Sr. Member
****
Karma: 8
Posts: 272
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all!

I'm using an ATMega328p that's running at 8 MHz, using the internal oscillator.
It's hooked up to a serial LCD display using a modified version of the SoftwareSerial library (long story, don't ask smiley ).

The problem I'm having is that when I first power the setup, the serial communication does not seem stable and the timing seems to be all off, resulting in garbled characters on the display. I thought that might be a oscillator calibration problem, but my logic analyzer confirms that after an initial period,the timing is absolutely spot on. There are just intermittent frame errors in the first few seconds.

Does the internal oscillator need time to settle or something?
If so, any bets on what a safe time to wait for that would be?

Thx!
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3941
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Does the internal oscillator need time to settle or something?

Yes, but the datasheet indicates that 14 clock cycles plus 65ms should suffice, I wouldn't expect it to take seconds.

I might suspect the power supply, what are you using? Are there sufficient bypass capacitors in the circuit?

EDIT: But you don't have to explicitly wait the 14CK + 65ms (or whatever time is selected via the SUT and CKSEL fuse bits) as the MCU is held in reset for the specified period after power-on.
« Last Edit: September 10, 2013, 03:44:59 am by Jack Christensen » Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Offline Offline
Sr. Member
****
Karma: 8
Posts: 272
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, but the datasheet indicates that 14 clock cycles plus 65ms should suffice, I wouldn't expect it to take seconds.

Ok, that's reassuring, thanks.

Quote
I might suspect the power supply, what are you using? Are there sufficient bypass capacitors in the circuit?

And I suspect you're right smiley
No, I don't have enough (read: any) bypass capacitors.
It's a 12V desk power supply connected to a LM7805.

I'll add some capacitors...

Thanks!
Logged

Atlanta, USA
Offline Offline
Edison Member
*
Karma: 53
Posts: 1774
AKA: Ray Burne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
serial LCD display

My guess is the uC on the LCD to do the serial to parallel conversion is SLOW to initialize the LCD.  A delay in your setup() before dropping into loop() is probably all that is required.  Oh, some LCDs need a delay() after any Serial.clear()

Ray

Logged

Offline Offline
Sr. Member
****
Karma: 8
Posts: 272
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks guys!
You'll be shocked and completely surprised to learn that a capacitor fixed the problem smiley
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3941
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks guys!
You'll be shocked and completely surprised to learn that a capacitor fixed the problem smiley

Neither, given that there were none smiley-wink

But I also thought the LCD initialization was a good guess; it could have been both smiley-eek
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Anaheim CA.
Offline Offline
Faraday Member
**
Karma: 46
Posts: 2865
...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Missing, Wrong Value(s) or improperly placed bypass capacitors along with daisy chained instead of the preferable star ground topology has turned more good ideas and code into wasted time than ANY other reason I've ever seen in 20+ years of embedded controller design experience.
Holes are cheap the first time but terribly expensive after the fact.
 SMD pads even cheaper... A 'little' easier after the fact.
Free before (the pads), and the greatest thing is that too many is far better than too few. The simple truth is that not all need be used and those of no real value are simply dropped on the next revision of the board
I 'learned', finally what my Prof's were trying to pound into my thick skull... The hard way. Sometimes one can get lucky and change a handful of caps to larger values and add short fat jumpers to the larger caps... Not so lucky is to have to double all the cap values... But still real lucky compared to having to scrape solder-mask to add by-pass caps or truly unlucky when it was a 4 layer board and holes had to be drilled. Those of that complain bitterly today about poorly bypassed circuits made it... Those that didn't became technical writers... Which is why most data sheets make a passable attempt to be "Greek" in any language ("Greek" being any language you don't understand and not a slur on a fine and proud people).
I got so wounded by that issue that those Damn parts are the first things I look for. Now. Also the last to be trusted.

Doc
Logged

--> WA7EMS <--
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

Pages: [1]   Go Up
Jump to: