PIC24FV32KA301 internal clock

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

Moderator: Benj

Post Reply
RTJNair
Posts: 12
Joined: Sun Nov 09, 2014 5:53 pm
Location: Oman/India
Has thanked: 5 times
Been thanked: 2 times
Contact:

PIC24FV32KA301 internal clock

Post by RTJNair »

Hi Benj,

Really need your help in setting up the internal clock for PIC24FV32KA301. Flowcode works perfect in simulation mode.

Internal clock required: 8MHz

Understand we need to put a "c" code at the beginning of main. I tried ,

OSCCONbits.COSC=0b000; and also, OSCCON=0b000;

Both didn't work.

Is there anything else that I might have missed ?

Thanks in advance.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: PIC24FV32KA301 internal clock

Post by Benj »

Hello,

If you set the oscillator option in the configuration settings in the project options then this should set the initial value of the oscillator in the OSCCON register.

If you need to switch oscillators mid operation then you can do so using code like this.

Code: Select all

__builtin_write_OSCCONH(0x00);  //Initiate Clock Switch to 8MHz FRC
__builtin_write_OSCCONL(0x01);  //Start clock switching
while(OSCCONbits.COSC != 0b000);  //Wait for clock switch

//Wait for PLL to stabilise if using PLL
//while(OSCCONbits.LOCK != 1);
Remember to use the 1 second flasher test to double check everything is as expected.
https://www.matrixtsl.com/wikiv7/index. ... ED_flasher

RTJNair
Posts: 12
Joined: Sun Nov 09, 2014 5:53 pm
Location: Oman/India
Has thanked: 5 times
Been thanked: 2 times
Contact:

Re: PIC24FV32KA301 internal clock

Post by RTJNair »

Many thanks Benj for your quick reply.

Now, I could get it working and seems stable at 8MHz without PLL :D . I could also get a 0.96" SSD1306 I2C OLED working with it flawlessly at 400 Kbaud and with "no" stop delay.

RTJ Nair

Post Reply