Hi All,
Up until now i have always used a crystal with Pics but i am trying to get the internal osc running at 32mhz for my next project but cannot get it to run a program at the correct speed (turn out on, wait 1 sec, turn out off, wait 1 sec)
I have read the pic datasheet and i think i have done what it asks but it is still running really slowly, i have attached pictures.
I am also not sure what to set the project clock speed to in FC as the chip should be running at 32mhz so shouldn't it also be set for 32 and not the 8 that will be multiplied by 4?
Thanks
Ben
Here is the bit from the datasheet
5.2.2.6 32 MHz Internal Oscillator
Frequency Selection
The Internal Oscillator Block can be used with the 4X PLL associated with the External Oscillator Block to produce a 32 MHz internal system clock source. The following settings are required to use the 32 MHz internal clock source:
• The FOSC bits in Configuration Word 1 must be set to use the INTOSC source as the device system clock (FOSC<2:0> = 100).
• The SCS bits in the OSCCON register must be cleared to use the clock determined by FOSC<2:0> in Configuration Word 1 (SCS<1:0> = 00).
• The IRCF bits in the OSCCON register must be set to the 8 MHz HFINTOSC set to use (IRCF<3:0> = 1110).
• The SPLLEN bit in the OSCCON register must be set to enable the 4xPLL, or the PLLEN bit of the Configuration Word 2 must be programmed to a ‘1’.
The 4xPLL is not available for use with the internal oscillator when the SCS bits of the OSCCON register are set to ‘1x’. The SCS bits must be set to ‘00’ to use the 4xPLL with the internal oscillator.
Getting a 16F1937 to run at 32mhz
Moderator: Benj
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Getting a 16F1937 to run at 32mhz
Hi,
You just have a typo in your C icon, the code between /* and */ is ignored ...
You just have a typo in your C icon, the code between /* and */ is ignored ...
Code: Select all
/*
*/
OSCCON=0xF0;
-
- Posts: 37
- Joined: Tue May 14, 2013 8:18 pm
- Has thanked: 6 times
- Been thanked: 1 time
- Contact:
Re: Getting a 16F1937 to run at 32mhz
Nice one, that did it.
Is there anything i can run that would show what speed the pic is actually running at, with a crystal you know.
Ta
Ben
Is there anything i can run that would show what speed the pic is actually running at, with a crystal you know.
Ta
Ben
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Getting a 16F1937 to run at 32mhz
The best way of determine what frequency the oscillator is running at, is by doing the 1-second flash test
This can be done if using internal or external oscillator and is 100% reliable.
This can be done if using internal or external oscillator and is 100% reliable.
Martin