Please I need some help with PIC16F18855 - Page 1
Forum section: electronics / general

author: KYU_Skuizz
author_rank: Newbie
timestamp: September 24, 2024, 10:54:27 am
content: Hello everyone,I’m an apprentice electronics technician. I need to create a 32.768 kHz oscillator with a PIC16F18855 for an RTC (MCP79412) because I forgot to include a quartz crystal on my PCB.My first question is: can I make it using Timer2 or some other method? And how to make it ?Second question: In the MCP79412, X1 is the input, but what about X2? What is its purpose?If you have any other questions, don't hesitate, I'll respond as quickly as possible.Thanks

author: woofy
author_rank: Frequent Contributor
timestamp: September 24, 2024, 11:14:52 am
content: X2 is the output when using a 32KHz crystal.The MCP79412 will need to be put into external oscillator mode if you want to use the PIC.If you are using the internal oscillator in the PIC, don't bother, it won't be accurate enough for an RTC. If you are using an external crystal then it may be possible, but you haven't said what the frequency is.Note also it will not be able to keep time when the CPU is powered off. In that case you may as well just use the CPU to track time with a timer interrupt, until you can get the PCB revised.

author: JPortici
author_rank: Super Contributor
timestamp: September 24, 2024, 12:56:26 pm
content: You could use the NCO (which can run in power waving modes as well), though woofy has valid concerns about the clock source, if you're using the internal FRC you might as well ditch the RTC entirely and do it in software inside the PIC

author: voltsandjolts
author_rank: Unknown
timestamp: September 24, 2024, 01:11:53 pm
content: Why not just bodge a crystal onto the RTC pins?Get a crystal with legs and couple of small through-hole caps, job done.Tricky for TFDN package but possible.

author: KYU_Skuizz
author_rank: Newbie
timestamp: September 24, 2024, 01:24:34 pm
content: @woofyThank you for the answer. As I mentioned earlier, my PCB has already been ordered, so I cannot add anything else.For timekeeping, this is supposed to work normally. A battery has been placed on the Vbat pin of the RTC. However, I have the impression that without a crystal, I am in trouble; I suppose that the oscillation will not occur, and therefore my battery will be of no use.For accuracy, I might be able to tinker with something less than ideal to salvage what I can, but it won't be clean, that's for sure, and it won't be much more precise, ironic for a clock, haha (my project).You mentioned that I didn't provide the frequency, so I'm not sure I understood, so I will list them all here:Input frequency to the RTC: 32.768 kHzInternal PIC frequency: 4 MHzFrequency of my stupidity: at least four times a day.Sorry if I'm not specific with the terminology; I'm not a native English speaker.

author: KYU_Skuizz
author_rank: Newbie
timestamp: September 24, 2024, 01:27:58 pm
content: @JPorticiit could work, however, I have to use the RTC.Its in my requirements document :/

author: KYU_Skuizz
author_rank: Newbie
timestamp: September 24, 2024, 01:36:12 pm
content: Quote from: voltsandjolts on September 24, 2024, 01:11:53 pmI'm not sure I understand. Do I take a through-hole quartz and connect it directly to the pins of the RTC? It's funny because that's exactly the kind of tinkering I would do, haha.However, I didn't understand what "small through-hole caps" are. Could you explain that to me?

author: voltsandjolts
author_rank: Unknown
timestamp: September 25, 2024, 08:05:46 am
content: Quote from: KYU_Skuizz on September 24, 2024, 01:36:12 pmMaybe these parts:uk.farnell.com/4165725uk.farnell.com/2860107Assembly diagram: