View previous topic :: View next topic |
Author |
Message |
aaronik19
Joined: 25 Apr 2011 Posts: 297
|
32khz |
Posted: Sat Apr 18, 2020 1:24 pm |
|
|
Dear all,
I am using a pic18f and i also intergave the ds3231 module to my pic to make an alarm clock which is working pretty good. On the other hand i would like to use the timer0 to make some seconds timer and on the ds3231 there is a pin of 32khz frequency out. Is it possible to interface this pin to pic t0osc port since t0osc requires two pins and the ds3231 has only one pin of 32khz? Or maybe another solution, is it possible to convert the 32khz to 1hz and dedicate INT pin only to this 1hz? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19544
|
|
Posted: Sat Apr 18, 2020 1:54 pm |
|
|
Use the INT/SQW pin instead.
This can be programed to be a square wave pulse (The 'SQW'), at 1Hz, 1.024KHz, 4.096KHz, or 8.192KHz. Just feed this to the INT pin. |
|
|
aaronik19
Joined: 25 Apr 2011 Posts: 297
|
|
Posted: Sat Apr 18, 2020 1:56 pm |
|
|
Sorry i forgot to mention it. I am using the sqw 1hz as Interrupt when the alarm is reached. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9244 Location: Greensville,Ontario
|
|
Posted: Sat Apr 18, 2020 3:17 pm |
|
|
You should be able to connect it to the T0CKI pin and have timer0 count the pulses...
You'll need to read the 'timer0' chapter of whatever PIC you're using, as some conditions may have to be met. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19544
|
|
Posted: Sun Apr 19, 2020 12:37 am |
|
|
OK. If you are already using the INT output for an alarm, then
yes, you can count the 32K output.
It's always worth telling us the chip involved. PIC18, covers many
hundreds of different chips and there are 'detail' differences in what they
can actually do. The programming needed differs for different chips.
If you look at a basic PIC18 like the F452, the Timer0, input selection
has a simple option T0_EXT_L_TO_H which has it counting the low to high
transitions on T0CKI. However later chips that offer oscillators have
options like:
Quote: |
#define T0_INTERNAL 0x8050
#define T0_HFINTOSC 0x8060
#define T0_LFINTOSC 0x8080
#define T0_MFINTOSC 0x80A0 //500 kHz
#define T0_SOSC 0x80C0
#define T0_CLC1 0x80E0
#define T0_EXT_L_TO_H 0x8000
#define T0_EXT_H_TO_L 0x8020
#define T0_OFF 0
|
Allowing the clock to come from the secondary oscillator or again
from the external clock pin. On these more complex chips you may
have to actually specify what pin to use for the T0 clock input with
PPS.
Details of how to set this up, depend on what chip you are using. |
|
|
|