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.
PIC24FV32KA301 internal clock
Moderator: Benj
- 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
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.
Remember to use the 1 second flasher test to double check everything is as expected.
https://www.matrixtsl.com/wikiv7/index. ... ED_flasher
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);
https://www.matrixtsl.com/wikiv7/index. ... ED_flasher
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- 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
Many thanks Benj for your quick reply.
Now, I could get it working and seems stable at 8MHz without PLL . I could also get a 0.96" SSD1306 I2C OLED working with it flawlessly at 400 Kbaud and with "no" stop delay.
RTJ Nair
Now, I could get it working and seems stable at 8MHz without PLL . I could also get a 0.96" SSD1306 I2C OLED working with it flawlessly at 400 Kbaud and with "no" stop delay.
RTJ Nair