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)
Secondary oscillator on a PIC16F18425
-
- Posts: 9
- http://meble-kuchenne.info.pl
- Joined: Sat Jan 30, 2021 3:42 pm
Secondary oscillator on a PIC16F18425
- Attachments
-
- Sosc_setting.fcfx
- (13.19 KiB) Downloaded 227 times
-
- Matrix Staff
- Posts: 1624
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 576 times
- Been thanked: 543 times
Re: Secondary oscillator on a PIC16F18425
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:
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:
Martin
Re: Secondary oscillator on a PIC16F18425
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
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
-
- Matrix Staff
- Posts: 1624
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 576 times
- Been thanked: 543 times
Re: Secondary oscillator on a PIC16F18425
No, only set it for HFINOSC 32MHz. 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
Re: Secondary oscillator on a PIC16F18425
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
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 213 times