Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 09:00 08 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : DS3231 Interrupt Pulse

Author Message
Justplayin

Guru

Joined: 31/01/2014
Location: United States
Posts: 327
Posted: 11:25am 17 Aug 2016
Copy link to clipboard 
Print this post

Does anyone have some MMBasic code which will setup a DS3231 clock module to output a interrupt pulse once every second? I know someone posted similar code for a PCF8563 module a while back, but I would like to use a DS3231.

Thanks,
--Curtis
I am not a Mad Scientist...  It makes me happy inventing new ways to take over the world!!
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 09:28pm 17 Aug 2016
Copy link to clipboard 
Print this post

The SQW pin is a 1 Hz Square Wave output on some DS3231 modules
 
Justplayin

Guru

Joined: 31/01/2014
Location: United States
Posts: 327
Posted: 09:58am 18 Aug 2016
Copy link to clipboard 
Print this post

  lew247 said   The SQW pin is a 1 Hz Square Wave output on some DS3231 modules


My modules have no output on SQW (yet), so I need to program them to provide one. Finally found TassyJim's code for the PCF8563 and tried it on a DS3231... As expected it didn't work.

--Curtis
I am not a Mad Scientist...  It makes me happy inventing new ways to take over the world!!
 
mikeb

Senior Member

Joined: 10/04/2016
Location: Australia
Posts: 174
Posted: 10:45am 18 Aug 2016
Copy link to clipboard 
Print this post

The default squarewave frequency is 8192 Hz. You have to set 2 bits in the option register, in the RTC chip, to one of 4 options. Haven't got the datasheet on me at the moment but I thing that the output is disabled, by default, also.
There are 10 kinds of people in the world.
Those that understand binary and those that don't.
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1573
Posted: 01:11pm 18 Aug 2016
Copy link to clipboard 
Print this post

@curtis

Maybe this is what you're looking for?
Dim crtl_reg%=0
RTC GETREG &H0E,crtl_reg%
Print Bin$(crtl_reg%)
'76543210
RTC SETREG &H0E,crtl_reg% And &B01100011 'clear bit 7,4,3,2


Bit 4,3 are for the frequency
0,0=1Hz
0,1=1.024kHz
1,0=4.096kHz
1,1=8.192kHz


Regards
Michael

EDIT
You will find the description of the control register (0Eh) at page 13 in Maxims datasheet for the DS3231.

In some cases it may be sufficient to set the control register (0Eh) to zero (for 1Hz SQW output).
RTC SETREG &H0E,0
Edited by twofingers 2016-08-19
causality ≠ correlation ≠ coincidence
 
Justplayin

Guru

Joined: 31/01/2014
Location: United States
Posts: 327
Posted: 03:55pm 18 Aug 2016
Copy link to clipboard 
Print this post

Thanks Michael,

I think that may do it. There is output on the SQW pin now!

Been staring at the DS3231 data sheet all day. I could see what I wanted to change, but wasn't sure how to get to the register. Total forgot the RTC command provides access to the RTC registers.

A few more tests and I should be able to move forward again!

--CurtisEdited by Justplayin 2016-08-20
I am not a Mad Scientist...  It makes me happy inventing new ways to take over the world!!
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025