View previous topic :: View next topic |
Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Apr 29, 2009 9:28 pm |
|
|
This program works.
Code: | #include <18F4620.h>
#fuses INTRC_IO,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
#use delay(clock=32000000)
//====================================
void main()
{
setup_oscillator(OSC_32MHZ | OSC_PLL_ON);
while(1)
{
output_high(PIN_B0);
delay_ms(500);
output_low(PIN_B0);
delay_ms(500);
}
} |
|
|
|
C Turner
Joined: 10 Nov 2003 Posts: 40 Location: Utah
|
Trying to get the 4620's PLL to work with the internal clock |
Posted: Thu Apr 30, 2009 10:22 am |
|
|
I see the problem: You *can't* turn on OSCCON bits 0 or 1 and expect it to work. In other words, "Primary Oscillator" should be enabled, and NOT "Internal Oscillator Block."
Somehow, if you wanted to use the "Internal Oscillator Block" with the PLL, I'd have thought one might turn it on.
Stupid me!
Thanks for the help, PCM,
CT |
|
|
hobiadami
Joined: 17 Oct 2006 Posts: 35 Location: City of Concrete
|
pin change |
Posted: Thu Apr 26, 2012 3:18 pm |
|
|
can't I use the oscillator pins as I/O with this setup?
I've used the code above on real hardware just by changing the pin numbers to pin_a6 or a7 and didn't be able to blink a led connected to those pins.
I'm using 4.114 _________________ www.endtas.com |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Apr 26, 2012 5:28 pm |
|
|
Post your small compilable test program. |
|
|
hobiadami
Joined: 17 Oct 2006 Posts: 35 Location: City of Concrete
|
code |
Posted: Fri Apr 27, 2012 12:59 am |
|
|
Thanks for the reply,
The program is absolutely same as yours. I just changed the output pin. A6 and A7, didn't change anything. Other pins are okay. Only the oscillator pins don't blink the led. I've tested with a brand new 18F4620 as well.
Code: |
#include <18F4620.h>
#fuses INTRC_IO,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
#use delay(clock=32000000)
//====================================
void main()
{
setup_oscillator(OSC_32MHZ | OSC_PLL_ON);
while(1)
{
output_high(PIN_A6);
delay_ms(500);
output_low(PIN_A6);
delay_ms(500);
}
} |
_________________ www.endtas.com |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19503
|
|
Posted: Fri Apr 27, 2012 4:04 am |
|
|
Change to:
Code: |
#include <18F4620.h>
#fuses INTRC_IO,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
#use delay(clock=32000000)
//====================================
void main(void) {
setup_oscillator(OSC_32MHZ | OSC_INTRC);
while(TRUE) {
output_high(PIN_A6);
delay_ms(500);
output_low(PIN_A6);
delay_ms(500);
}
}
|
This is one of those nasty little 'compiler version' ones.
First, OSC_32_MHZ, includes the PLL_ON bit, Doesn't matter to duplicate it, but doesn't actually do anything.
However key is that on some compilers, the OSC_xxMHz settings, for the two PLL modes, don't have the select to say 'use the internal oscillator'. When the PLL is selected, the internal oscillator is not defined as the primary oscillator (oddity of the chip...), so if you use them without specifying this, they switch to 'OSC_NORMAL', which then doesn't work, and the chip stops. Hence then your pin doesn't toggle....
Best Wishes |
|
|
hobiadami
Joined: 17 Oct 2006 Posts: 35 Location: City of Concrete
|
:) |
Posted: Sat Apr 28, 2012 1:35 pm |
|
|
Thanks Thelmah, this solved it. _________________ www.endtas.com |
|
|
|