Secondary oscillator on a PIC16F18425

Use this section to discuss your embedded Flowcode projects.
Post Reply
ianjoh
Posts: 8
http://meble-kuchenne.info.pl
Joined: Sat Jan 30, 2021 3:42 pm

Flowcode v10 Secondary oscillator on a PIC16F18425

Post by ianjoh »

Hi all

I am trying to set up a secondary oscillator using a 32.768 KHz xtal to give an accurate tick for a timing counter.
Looking at the data sheet on page 8 pin allocation table it would seem that the SOSC shares the same block on pins 2 & 3 as the OSC1 & OSC2 which is ok as I will use the INT OSC to run the PIC, however I cannot get the interrupt to trigger on the SOSC, It will if I set the interrupt to EXT OSC and run everything from a 4meg xtal.
LEDS on C1 and C5 flash at the expected rate but C2 which is on the SOSC is permanently on.

The reason for doing this is I am finding the 4 MHz xtals that are on the boards are not keeping time with each other unless I match them before assembly which is not practical long term so I thought I could switch the non critical timing to the INTOSC and use a 37KHz timing xtal as a SOSC without changing the pcb design.
I hope I am not trying to achieve the impossible!

Thanks Ian


(edited into correct section)
Attachments
Sosc_setting.fcfx
(13.19 KiB) Downloaded 32 times

medelec35
Matrix Staff
Posts: 1480
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 525 times
Been thanked: 481 times

Re: Secondary oscillator on a PIC16F18425

Post by medelec35 »

Hello Ian.
I have not got your target device to check with, so I can't test if my answer is correct.
If it was me, I would set the project options for internal oscillator for your desired frequency, e.g 32MHz.
Connect the crystal and caps to the SOSC pins and then select the SOSC source from Timer0 interrupt only.
Hopefully, that will work.
If it does not work for you then you will need to check SOSCO for the correct frequency as you could have a cap mismatch?

The reason I believe it will work is down to the green path:
SOSC path.png
SOSC path.png (56.69 KiB) Viewed 820 times
Martin

ianjoh
Posts: 8
Joined: Sat Jan 30, 2021 3:42 pm

Re: Secondary oscillator on a PIC16F18425

Post by ianjoh »

Hi Martin
Thank you for your reply.

I have been waiting for some new crystals and matching caps rather than the lucky scrap bin find.
32.768 KHz crystal on pins 2 & 3 and Timer0 as your suggestion
If I set the Software Oscillator Mode to EXTOSC I get oscillation on the 'scope and the PIC runs (slowly!)
If I set the Software Oscillator Mode to SOSC 32.768Khz the crystal stops dead.

There must be a bug in the settings somewhere. Its like there are not enough options in the dropdown to set to SOSC and HFINOSC 32MHz

Would it be possible to look into this for me please.
Happy to send you a PIC

Thanks
Ian

medelec35
Matrix Staff
Posts: 1480
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 525 times
Been thanked: 481 times

Re: Secondary oscillator on a PIC16F18425

Post by medelec35 »

ianjoh wrote:
Thu May 16, 2024 11:15 pm
There must be a bug in the settings somewhere. Its like there are not enough options in the dropdown to set to SOSC and HFINOSC 32MHz
No, only set it for HFINOSC 32MHz.
Config settings OSC.png
Config settings OSC.png (17.23 KiB) Viewed 789 times
SOSC is only set within timer 0
Make sure the clock is running at the desired speed e.g 32MHz, by running a 1 sec flasher test.
Martin

ianjoh
Posts: 8
Joined: Sat Jan 30, 2021 3:42 pm

Re: Secondary oscillator on a PIC16F18425

Post by ianjoh »

HI Martin

That setting still does not trigger the interrupt as the 32Khz crystal is not oscillating, pins 2 & 3 are firmly off.
I have tried just about every setting available! I think the confusion with the FC is that the SOSC uses the same pins as OSC1 & OSC2 so when they are off so is the SOSC.
The clock source block diagram has the SOSC has it as a separate input and block but that may just be a generic diagram.
The 1 second tick is working correctly at 32MHz!

Thanks
Ian
Attachments
Sosc_setting.fcfx
(13.25 KiB) Downloaded 29 times

Post Reply