I'm trying to recall the math behind the 32.768 kHz number ...... I use a crystal for 32.768 kHz for TMR1. That gives a nice 2-second pace.
Many thanks for your help. Question, wouldn't having two clock sources drain more power from the mcu?No, no, no... Use the INTOSC for the system clock. The LP TMR1 Oscillator with 32.768-kHz crystal drives the 16-bit TMR1 counter.
If you want 1-second interrupt intervals with the 32768-Hz LP TMR1 OSC simply set bit 7 of TMR1H register each time you enter the TMR1 interrupt routine. This forces TMR1 to overflow every 32768 counts (1-second) instead of every 65536 counts (2-seconds).
There's a C code example using a 16F1828 at Project: PIC 4-Digit Single-Chip 24 Hour Clock which may be helpful (?)...
Cheerful regards, Mike
![]()
But aren't the TMR1 registers the timekeepers themselves? Wouldn't altering their value in any way also affect timekeeping?Two seconds is fine and is what I actually use. But setting bit 7 of TMR1H is simple (an RMW instruction with BSF) , and if done reasonably soon after an interrupt, there is no worry about missing a rollover from TMR1L. That will give you a 1 sec pulse as suggested by MMcLaren. I just forgot to mention it in my post.An advantage to 8-bit registers?
As for the rest, TMR1 is powerful. That's what I use for my smart roast thermometer to capture and average readings, etc.
oh ... now I need to know about your roast project ... maybe you could post it at the Grill thread?I have never cooked a roast when 1 second made a difference.![]()
It will be. The PCB's came from Oshpark just as Spring broke. It will be my first reflow project with solder paste. It is on hold until until the ground hogs hibernate.oh ... now I need to know about your roast project ... maybe you could post it at the Grill thread?
Are you going to make your own stencils? If so, may I offer my assistance?It will be. The PCB's came from Oshpark just as Spring broke. It will be my first reflow project with solder paste. It is on hold until until the ground hogs hibernate.
I got SS stencils from Oshstencil (https://www.oshstencils.com/# ). It is not officially related to Oshpark, but friendly with it and very fast production with free shipping in the US. Something like 2 days from order to receipt on a Saturday. By avoiding the cost of international shipping, the cost was less that of the Asian suppliers for SS.Are you going to make your own stencils? If so, may I offer my assistance?
That is understandable. But wouldn't it be the same to instead of externally pulling up an unused input to just activate its internal weak pull up?I/O pins that are high-impedance inputs should be pulled to VDD or VSS externally to avoid switching currents caused by floating inputs.
The data sheet isn't exactly clear on that; I should think the internal weak pullup would suffice, but I'm not 100% certain.But wouldn't it be the same to instead of externally pulling up an unused input to just activate its internal weak pull up?
That's what I've been doing.Or wouldn't it be best to simply define any unused pin as an output and set it low while leaving it unconnected?
Dunno.Which configuration for unused pins is best for minimizing power draw?

Doesn't really answer my question. But further down in the same page, it's stated that:Unused Port Pins
If a port pin is unused, it may be left unconnected but configured as an output pin driving to either state (high or low), or it may be configured as an input with an external resistor (about 10 kΩ) pulling it to Vdd or Vss.
If configured as an input, only the pin input leakage current will be drawn through the pin (the same current would flow if the pin was connected directly to Vdd or Vss). Both options allow the pin to be used later for either input or output without significant hardware modifications.
So I guess that answers it. It's probably best to leave unused pins as outputs set low.Digital Outputs
There is no additional current consumed by a digital output pin other than the current going through the pin to power the external circuit. Pay close attention to the external circuits to minimize their current consumption.