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
Cannot configure Internal Oscillator
Moderator: Benj
Cannot configure Internal Oscillator
- Attachments
-
- Screenshot IntOsc Helper.jpg (46.79 KiB) Viewed 4320 times
-
- Screenshot General Options.jpg (28.25 KiB) Viewed 4320 times
-
- Screenshot Configure.jpg (81.45 KiB) Viewed 4320 times
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
Re: Cannot configure Internal Oscillator
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
edit :Sorry just saw now chipfryer is correct I saw 1 zero to many
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
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
edit :Sorry just saw now chipfryer is correct I saw 1 zero to many

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
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
-
- Valued Contributor
- Posts: 786
- Joined: Fri Jun 06, 2014 3:53 pm
- Has thanked: 187 times
- Been thanked: 205 times
Re: Cannot configure Internal Oscillator
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
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
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
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
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Cannot configure Internal Oscillator
Hi Clive,
For 64 MHz
Can you try setting internal clock speed to 64000000.
Then add C code block with
Also If display is not working,
Try setting SPI to software mode.
If that fails then try at 32MHz
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);
Try setting SPI to software mode.
If that fails then try at 32MHz
Martin
Re: Cannot configure Internal Oscillator
Thanks Martin
I'll try what you suggested and let you know the results!
Cheers
Clive
I'll try what you suggested and let you know the results!
Cheers
Clive
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Cannot configure Internal Oscillator
Your'e welcome Clive.
It's my understanding that PLL in options is for crystal only and is for internal OSC only?
It's my understanding that PLL in options is for crystal only and
Code: Select all
st_bit(OSCTUNE,PLLEN);
Martin
Re: Cannot configure Internal Oscillator
Hi Martin
Sory I've taken so long to get back to you!
That works - thanks for your help. Much appreciated.
Clive
Sory I've taken so long to get back to you!
That works - thanks for your help. Much appreciated.
Clive