![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Torello
Joined: 29 Sep 2006 Posts: 118
|
setup_oscillator, OSC_INTRC, OSC_31Khz, too high current |
Posted: Sun Jan 06, 2008 6:02 am |
|
|
Hi,
I found out that setting up the oscillator with setup_oscillator(OSC_INTRC | OSC_31KHZ) does not select the 31Khz output from the internal oscillator block.
The cause of this lays in not clearing the INTSRC bit when calling this function. CCS set this bit as default as entry of the Main() function. You will find
...
00562: CLRF FD3 //clear osccon
00564: MOVLW 80 //load 0x80 in W
00566: MOVWF F9B //mov W to Osctune;
>> BIT INTSRC is SET, this enables the divide-by-256 and selects the 31.250 source (or one of the others depending on the bits in OscCon)
..
then setup_oscillator(OSC_INTRC | OSC_31KHZ) is only compiled to:
00580: MOVLW 02
00582: MOVWF FD3
00584: MOVF FD3,W
Thus NOT clearing the INTSRC bit anymore.
I found this issue because I want to run the PIC(LF4620) in it's lowest power; 31Khz RC-mode. This should, according to the datasheet, draw max 60uA at Vdd=3v. Before finding this issue the current was ~230uA. Almost 4 times too high, so something had to be wrong. After clearing the INTRC bit, it now runs at ~40uA
My conclusion, besides the CCS bug, is that the enabling the postscaler draws about 190uA ! That is relatively lot off current for a little faster ;-)
Kind regards,
Edwin
CCS version 4.064 |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Sun Jan 06, 2008 8:06 am |
|
|
What _fuse_ setting are you putting for the oscillator?.
If you select _LP_, then the compiler assumes you want the low power 31KHz mode. If you select any other mode, then it assumes you want the high power mode, and behaves as you describe.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
Torello
Joined: 29 Sep 2006 Posts: 118
|
|
Posted: Sun Jan 06, 2008 8:47 am |
|
|
I'm using INTRC_IO. According to the datasheet the LP fuse should be used when an external crystal/resonator is used. I want to use the internal oscillator block.
Quote: |
In XT, LP, HS or HSPLL Oscillator modes, a crystal or
ceramic resonator is connected to the OSC1 and
OSC2 pins to establish oscillation. Figure 2-1 shows
the pin connections.
|
regards,
Edwin |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Sun Jan 06, 2008 8:56 am |
|
|
You'll find if you select LP, it'll default to the low power operation. It is perhaps not following the data sheet, but it is the way that CCS does it...
What is silly, is that they have a separate 'OSC_31250' setup, which enables the high current mde, but the OSC_31KHz, doesn't turn it off. Report it as a bug, since it is wrong.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|