Getting a 16F1937 to run at 32mhz

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
beneee
Posts: 37
Joined: Tue May 14, 2013 8:18 pm
Has thanked: 6 times
Been thanked: 1 time
Contact:

Getting a 16F1937 to run at 32mhz

Post by beneee »

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.
fc.PNG
(18.22 KiB) Downloaded 187 times
config.PNG
(19.62 KiB) Downloaded 187 times
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.

User avatar
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

Post by LeighM »

Hi,
You just have a typo in your C icon, the code between /* and */ is ignored ...

Code: Select all

/*
*/
OSCCON=0xF0;


beneee
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

Post by beneee »

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

medelec35
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

Post by medelec35 »

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.
Martin

Post Reply