I have made a LED clock and it works nicely with a 16F1509. I am trying to make another using a 16F18346 and I can't seem to get the chip to run off the 32768 Hz crystal oscillator.
Here's the relevant parts of the two programs
Thanks for the reply Jim. I am actually running the whole thing at 32kHz (including the processor). Because the whole thing is running on batteries I am trying to keep the current down. The LED multiplexing is fine at this clock rate and it keeps the current low.
I just had a thought that it may be Timer1 that is the problem, but I could see no obvious differences in the datasheets between the two chips.
I will attach the full program (the one that works for the 16F1509).
Check the demos. There are examples for the 156. And, there a long thread discussing the issues with the new chip architecture and these types of clocks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Can you point me to the relevant demos. Most seem to be using RTCs and running the chip at 32 MHz.
Just to summarize I am trying to get the processor to run at 32768Hz using a clock crystal. The Timer1 is taking this divided by 4 (Fosc/4) then a 8:1 prescaler. This should cause the timer to roll-over every 64 seconds and generate an interrupt (setting TMR1H to 00010000 reduces this to 60 seconds).
It works great on a 1509 (its been running for almost a year on 2xAAA), but the oscillator settings on the 18324 don't seem to work in the same way.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The configuration I posted above does in fact work. The stalling was due to a light sensor not being fitted (the clock is intended for nightime use so the display switches off when it is too light to see).
So the key is to set osccon1.
Strangely the first "minute" is still 45 sec, but subsequent minutes are all exactly 60 secs.
This does not matter as the time will have to be set after power-up, but it is none less curious anomaly.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have made a LED clock and it works nicely with a 16F1509. I am trying to make another using a 16F18346 and I can't seem to get the chip to run off the 32768 Hz crystal oscillator.
Here's the relevant parts of the two programs
So the top one works and the bottom one ticks off 2hours in 15 seconds.
For those chips, using a 32k clock crystal, here's what I've been using-
Thanks for the reply Jim. I am actually running the whole thing at 32kHz (including the processor). Because the whole thing is running on batteries I am trying to keep the current down. The LED multiplexing is fine at this clock rate and it keeps the current low.
I just had a thought that it may be Timer1 that is the problem, but I could see no obvious differences in the datasheets between the two chips.
I will attach the full program (the one that works for the 16F1509).
Thanks for the program, I'm learning new stuff from your code. I'm going to wire it up a play :)
Hopefully someone more knowledgeble will answer your question. (Evan???)
Check the demos. There are examples for the 156. And, there a long thread discussing the issues with the new chip architecture and these types of clocks.
Can you point me to the relevant demos. Most seem to be using RTCs and running the chip at 32 MHz.
Just to summarize I am trying to get the processor to run at 32768Hz using a clock crystal. The Timer1 is taking this divided by 4 (Fosc/4) then a 8:1 prescaler. This should cause the timer to roll-over every 64 seconds and generate an interrupt (setting TMR1H to 00010000 reduces this to 60 seconds).
It works great on a 1509 (its been running for almost a year on 2xAAA), but the oscillator settings on the 18324 don't seem to work in the same way.
Slight progress I have set OSCCON1 bits to external OSC and now timer1 overflows in 45 seconds (should be 60) then the program stalls.
~~~~~~
config fextosc=lp,rstosc=ext1x, mclre_off, WDTE=off, CLKOUTEN_OFF
'extosc=lp on reset use fextosc for osc
t1con=b'00110001'
osccon1=b'01110000' 'select fextosc
oscen.7=1 'enable extosc
~~~~~~~
Last edit: David Stephenson 2019-10-16
Look at https://github.com/Anobium/Great-Cow-BASIC-Demonstration-Sources/blob/master/Real_Time_Clock_Solutions/RTCC_Microchip_16F19156_I2C_LCD_VBATEN.gcb and microchiprtcc.h
The .h has the key information in the init method.
Evan
The configuration I posted above does in fact work. The stalling was due to a light sensor not being fitted (the clock is intended for nightime use so the display switches off when it is too light to see).
So the key is to set osccon1.
Strangely the first "minute" is still 45 sec, but subsequent minutes are all exactly 60 secs.
This does not matter as the time will have to be set after power-up, but it is none less curious anomaly.