Page 1 of 1
Cannot configure Internal Oscillator
Posted: Wed Oct 28, 2020 2:34 pm
by Clive44
Hi
I've had trouble getting a graphics LCD ILI9341 to work on SPI.
I'm using a PIC18F45K22 with the internal RC Oscillator.
When I run the '1 second test' it is 8 x slow. i.e. 8 seconds up, 8 seconds down instead of 1 second up, 1 second down.
I have attached some screen shots.
What am I doing wrong?
Thanks
Clive
Re: Cannot configure Internal Oscillator
Posted: Wed Oct 28, 2020 3:00 pm
by QMESAR
Hi
I never used this chip however I haven't seen a PIC18 that can run at 80Mhz the max I expects 64Mhz
I would guess that in the OSC Helper you select the Internal OSC speed as 16Mhz (click on the OSC parameter and a list box will open that shows the various speeds the Internal OSC can run at.
Then select 16MHz with your 4 times PLL enabled that = 64 Mhz also set the Clock frequency in the Flowcode Properties as 64MHz and try again do not forget to write the new OSC helper value for the OSCCON to the OSCCON regsiter with a C Icon
![p1.jpg](./download/file.php?id=32859&sid=1fa6cb542e76950fff2bfb8c4afde63c)
- p1.jpg (25.44 KiB) Viewed 3686 times
![P2.jpg](./download/file.php?id=32860&sid=1fa6cb542e76950fff2bfb8c4afde63c)
- P2.jpg (13.42 KiB) Viewed 3686 times
edit :
Sorry just saw now chipfryer is correct I saw 1 zero to many ![Very Happy :D](./images/smilies/icon_biggrin.gif)
However 8Mhz with PLL enabled is not 8Mhz Clock ,that would be 32Mhz assuming the the PLL has an effect with Internal OSC something to check from the data sheet
Re: Cannot configure Internal Oscillator
Posted: Wed Oct 28, 2020 3:36 pm
by chipfryer27
Hi
Looks like you have a "typo" in your C-Code block. You accidentally put your Osconn setting within the comment parameters.
In your C-Code block, just have :-
OSCONN=0x60;
Regards
Re: Cannot configure Internal Oscillator
Posted: Wed Oct 28, 2020 8:31 pm
by Clive44
Hi chipfryer27 and QMESAR
Thanks for your help and advice.
I've spent some time 'playing' this afternoon and these are the results -
In all Tests below, The Oscillator Selection Bits (In the Configure tab) is set to "Internal Oscillator block, CLKOUT function on RA6, port function on RA7
TEST NO.1
In General Options - Clock Speed set to 64,000,000
In Configure - 4 x PLL Enable - Enabled
OSCCON not used in the flowchart
RESULTS - FAIL
1 sec on RA0 actually measures 64 seconds!
CLKOUT on RA6 = 250KHz
ie Internal oscillator running at 1MHz not 64MHz
TEST NO.2
In General Options - Clock Speed set to 16,000,000
In Configure - 4 x PLL Enable - Enabled
OSCCON not used in the flowchart
RESULTS - FAIL
1 sec on RA0 actually measures 16 seconds
CLKOUT on RA6 = still 250KHz
ie Internal oscillator running at 1MHz not 64MHz
TEST NO.3
In General Options - Clock Speed set to 16,000,000
In Configure - 4 x PLL Enable - Enabled
OSCCON set to 0x70 (16MHz) in flowchart
RESULTS - PASS
1 sec on RA0 actually measures 1 second!
CLKOUT on RA6 = 4MHz
ie Internal oscillator running at 16MHz
TEST NO.4
In General Options - Clock Speed set to 16,000,000
In Configure - 4 x PLL Enable - Disabled
OSCCON set to 0x70 (16MHz) in flowchart
RESULTS - PASS
1 sec on RA0 actually measures 1 second!
CLKOUT on RA6 = 4MHz
ie Internal oscillator running at 16MHz
So the 4 x PLL option doesn't do anything?
Also the only way to get the internal oscillator to run at 16MHz is via the OSCCON command. Whatever you set in General options seems to be ignored?
I've ordered in some PIC18F47K40 chips to try to see if they perform the same.
Regards
Clive
Re: Cannot configure Internal Oscillator
Posted: Wed Oct 28, 2020 10:10 pm
by medelec35
Hi Clive,
For 64 MHz
Can you try setting internal clock speed to 64000000.
Then add C code block with
Code: Select all
OSCCON = 0x70;
st_bit(OSCTUNE,PLLEN);
Also If display is not working,
Try setting SPI to software mode.
If that fails then try at 32MHz
Re: Cannot configure Internal Oscillator
Posted: Fri Oct 30, 2020 4:29 pm
by Clive44
Thanks Martin
I'll try what you suggested and let you know the results!
Cheers
Clive
Re: Cannot configure Internal Oscillator
Posted: Sat Oct 31, 2020 4:59 pm
by medelec35
Your'e welcome Clive.
It's my understanding that PLL in options is for crystal only and
is for internal OSC only?
Re: Cannot configure Internal Oscillator
Posted: Thu Nov 19, 2020 7:13 pm
by Clive44
Hi Martin
Sory I've taken so long to get back to you!
That works - thanks for your help. Much appreciated.
Clive