|
|
View previous topic :: View next topic |
Author |
Message |
Guest
|
internal oscillator block PIC18F2480 |
Posted: Fri Sep 22, 2006 7:20 pm |
|
|
hello,
I am using a PIC18F2480. I'd like to use the internal oscillator @ 8MHZ. I can't seem to get it to oscillate. Any suggestions on the code? I'm confused about the proper #fuse to include. also the setup_oscillator function is kind of vague in the book.
Any help would be appreciated |
|
|
Douglas Kennedy
Joined: 07 Sep 2003 Posts: 755 Location: Florida
|
|
Posted: Fri Sep 22, 2006 7:47 pm |
|
|
Try this
Code: | #FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#fuses NOLVP,NOWDT,NOPUT,NOBROWNOUT,NOCPD,NOWRT,NOEBTR,NOPROTECT
#use delay(clock=8000000)
void main()
{
setup_oscillator(OSC_8MHZ);
while(1);
} |
|
|
|
skenn_ie
Joined: 16 Oct 2006 Posts: 1 Location: Ireland
|
|
Posted: Mon Oct 16, 2006 6:20 pm |
|
|
I'm having a similar problem. Tried the code suggested, but still no clock.
How should this code appear in the "device configuration" bits of the programmer software ? I'm using an 18F2620, and WinPic |
|
|
Eugeneo
Joined: 30 Aug 2005 Posts: 155 Location: Calgary, AB
|
|
Posted: Wed Oct 18, 2006 3:16 am |
|
|
Is there a setup directive built in to CCS for the osctune register? If not you're going to have to set the internal osc PLL bits somthing like this.
Code: |
#byte osctune=0xF9B
setup_oscillator(OSC_8MHZ);
osctune = 0b1100000; // PLL ON, center freq.
|
|
|
|
Ttelmah Guest
|
|
Posted: Wed Oct 18, 2006 4:46 am |
|
|
It would help, first of all, if you said what compiler version?.
The 'setup_oscillator' call, should set the oscillator up correctly. It also should probably be unneccessary. The latter compilers, if the 'use delay' statement, is on the very next line after the fuses, will automatically set the oscillator up. However this should not matter, having the chip setup 'twice', should make no difference. I'd tend to 'err' to adding this as a safety feature.
On Douglas's 'demo' code, how are you ever going to 'know' that the code as shown is working or not?. There is no output going to occur anywhere to actually test what is happening. Adding a pulse output in the while, would prove just what speed the chip is running.
One thing that would stop the chip waking up, would be if 'the MCLR line is not connected, and the 'NOMCLR' fuse has not been set. The chip will not start, till this pin goes high, unless the pin is disabled.
Best Wishes |
|
|
|
|
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
|