[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [avr-gcc-list] OT: anyone successfully use the CLKPR feature in them
From: |
larry barello |
Subject: |
RE: [avr-gcc-list] OT: anyone successfully use the CLKPR feature in themega88? |
Date: |
Tue, 3 Oct 2006 09:53:37 -0700 |
Ok, if you insist. It just is so off topic...
Anyway, I have a little app, and when I want to snooze, rather than shutting
down & using the watchdog to wake up, I thought I would use that handy
looking CLKPR register to slow the main clock waaay down. Then, when
interrupted (via the Timer0 main heartbeat, but now 1/128 slower...) I would
bump the clock back up to do my processing, etc.
The overt symptoms are that the clock doesn't bump up reliably. I suspect
that it doesn't bump down reliably either, but at 11mhz & 50hz timer tick I
wouldn't notice the code taking several tries. @ 100khz and .5 hz I notice
when it misses as a complete control cycle occurs at a glacial pace...
I tried many variations and finally settled on the code, below, which still
isn't reliable. I toggle between 0x00 and 0x06 divisors.
void SetClock(uint8_t divisor)
{
cli();
asm("nop");
asm("nop");
asm("nop");
asm("nop");
asm("nop");
asm("nop");
asm("nop");
asm("nop");
CLKPR = 0x80;
CLKPR = divisor; // Divide system
clock by 128.
asm("nop");
asm("nop");
asm("nop");
asm("nop");
asm("nop");
asm("nop");
asm("nop");
asm("nop");
}
The code, above, of course, resolves into two back-to-back STS instructions,
which, with interrupts off should do the trick.
| -----Original Message-----
| From: Eric Weddington [mailto:address@hidden
| Sent: Tuesday, October 03, 2006 8:12 AM
| To: 'larry barello'; 'AVR GCC List'
| Subject: RE: [avr-gcc-list] OT: anyone successfully use the CLKPR feature
| in themega88?
|
|
|
| > -----Original Message-----
| > From:
| > address@hidden
| > [mailto:address@hidden
| > org] On Behalf Of larry barello
| > Sent: Tuesday, October 03, 2006 8:35 AM
| > To: AVR GCC List
| > Subject: [avr-gcc-list] OT: anyone successfully use the CLKPR
| > feature in themega88?
| >
| > I am having difficulty with reliable transition between clock
| > speeds. I
| > have been using various AVR chips for years so I doubt I am
| > doing something
| > stupid, but, one never knows.
|
| Hi Larry,
|
| Long time, no see. ;-)
|
| What do you mean by "difficulty with reliable transition between clock
| speeds"? What are you seeing?
|
| > Please, reply direct rather than on the list.
|
| And deprive others from the answer? ;-) I'll reply to both direct *and*
| the
| list if that helps...
|
| Eric Weddington