Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: How do you change the clk speed?

2006-11-21 by Richard Cooke

Hi John,

Here's what the LST file shows:

;      66 void main(void)
                 ;      67 {
                 _main:
                 ;      68 // Declare your local variables here
                 ;      69 char status;
                 ;      70 unsigned int time = 0;
                 ;      71 
                 ;      72 // Crystal Oscillator division factor: 2
                 ;      73 #pragma optsize-
                 ;      74 CLKPR=0x80;
                 ;	status -> R16
                 ;	time -> R17,R18
000054 e010      	LDI  R17,0
000055 e020      	LDI  R18,0
000056 e8e0      	LDI  R30,LOW(128)       // set enable bit
000057 bde6      	OUT  0x26,R30        
                 ;      75 CLKPR=0x02;
000058 e0e2      	LDI  R30,LOW(2)         // divide by 2
000059 bde6      	OUT  0x26,R30


Sorry about the formatting - this is how the compiler writes it.  But
as far as I can tell the two writes are occurring one right after the
other.

Richard

--- In AVR-Chat@yahoogroups.com, John Samperi <samperi@...> wrote:
>
> At 08:35 AM 22/11/2006, you wrote:
> >  I'm writing an 0x80 to the register and the next
> >instruction is the CLKPR = 0x03 so it should be meeting the 4 cycle
> >restriction as stated in the manual.
> 
> Not necessarily....if it is written in C....BOOM..take cover..:)
> Have you looked at what the compiler is actually doing? (list file)
> May want to write that bit in assembler. Also there was something
> on another thread about having to wait another 4 clock cycles
> (undocumented feature) before it all happens, may be 4 nops?
> I think it was posted on this forum, may have to do a search.
> 
> Regards
> 
> John Samperi
> 
> ********************************************************
> Ampertronics Pty. Ltd.
> 11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
> Tel. (02) 9674-6495       Fax (02) 9674-8745
> Email: john@...
> Website  http://www.ampertronics.com.au
> *Electronic Design * Custom Products * Contract Assembly
> ********************************************************
>

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.