CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

32khz

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
aaronik19



Joined: 25 Apr 2011
Posts: 297

View user's profile Send private message

32khz
PostPosted: Sat Apr 18, 2020 1:24 pm     Reply with quote

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: 19540

View user's profile Send private message

PostPosted: Sat Apr 18, 2020 1:54 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Apr 18, 2020 1:56 pm     Reply with quote

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: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Apr 18, 2020 3:17 pm     Reply with quote

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: 19540

View user's profile Send private message

PostPosted: Sun Apr 19, 2020 12:37 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group