viewing a DS3232's time to check when to set a subroutine working.

banda

Member
I don't want to make a nuisance of myself in these forums ( fora ? ), but I find the manuals too difficult for a beginner to understand, and as well, I'm amazed at the information that's out there with the gurus willing to help people like me.

I've learned how to show a file, and that's what I'm doing.

It shows what I do to read the time on a DS3232. It reads the initial values I set to begin with, but I can't get it to access the time at any other time after the time I set to begin with. I am quite ready to believe I have missed some technique, and I'd be very pleased to be shown how to do it. What do I do ?

Another difficulty is where I convert BCD to DECIMAL, towards the end of the program. Why does the conversion need the # sign? I don't seem to be able to use the value to compare the clock's times with a decimal value of mine.

Thanks all for any help.


Code:
#picaxe 20M2
;clock DS3232

symbol secs = b0   ; DS3232 data
symbol mins = b1
symbol hour = b2
symbol dow  = b3
symbol days = b4
symbol mnth = b5
symbol year = b6
symbol cfg  = b7
symbol deci = b8

hi2csetup i2cmaster, %11010000, i2cslow, i2cbyte

;            SS   MM   HH DOW  DD   MM   YY.      Set date and time to 2001-02-28 23:59:45
hi2cout 0,( $45, $59, $23, 0, $28, $02, $01, $10 )

do
  ;hi2csetup i2cmaster, %11010000, i2cslow, i2cbyte  
  hi2cin 0,( secs, mins, hour, dow, days, mnth, year, cfg )       ; Read the DS3232 data
  pause 300
 	 
  b13 = secs
  b14 = b13/16*$FA+b13
  sertxd(#b14," ")
loop

end
 

banda

Member
Deep apologies. The conversion at the end does work.
It can be compared with decimal values.
I should have widened my investigation.
Mia culpa.
 

ac21

Member
The $10 after year i believe is for ds1307 to set 1hz output
Maybe your not setting everything up right?
This is how i set my time for ds3231, the red $00 will set 1hz output
Code:
[color=Green];'            secs  min  hrs  dow  date  mon   yr  A1sec  A1min  A1hou A1day  A2min  A2hou A2daydat ctrl ctrlstat aging,TempMSB,TempLSB)
;HI2Cout 0, ($00,  $57, $09, $01, $06,  $04, $14,  $00,   $00,  $00,   $00,   $00,   $00,   $00, [COLOR="#FF0000"]$00[/COLOR])[/color]
 

hippy

Technical Support
Staff member
hi2cout 0,( $45, $59, $23, 0, $28, $02, $01, $10 )
hi2cin 0,( secs, mins, hour, dow, days, mnth, year, cfg )
That is code for setting and reading a DS1307, not DS3232. See the datasheet and ac21's comment above.
 

banda

Member
First, thanks to ac21 and Hippy. I've changed the values they mention, and now it's all go. I can't believe I'd find that out on my own.

Also, thanks to westaust55 and eclectic. I have some explaining to do.

I now realise I was far too optimistic to attempt what I'm doing for my first project. I've had to learn everything right from scratch, but I think I've made some success in using i2C and DS3232 to time activities. There were still a few stumbling blocks to making my ideas work, so I sent out SOSes, and people showed me ways to go.

I had one particular very brief hint about alarms and interrupts that I thought was a great idea, but with no HOWTO to go with it.
You and eclectic gave me the fine details, but when I read your explanation of how to use alarms I knew your information was far more advanced than my beginning status could cope with.

I have stored your very carefully commented explanation away for when I gain more understanding, but decided to use my own rather clumsy program, because it was much simpler. I'm rather rapt with my nearly finished effort. I've refined it to something I think looks compact and tidy, and I think with all the help I've had it will work. I am testing it with seconds rather than hours, in PICAXE VSM, and I'll soon start transferring it to a breadboard.

I'd have the greatest trouble advancing so far without the help of people like you. The manuals are very difficult for beginners, so I hope people like you will bear with us and continue to give advice that will help beginners like me to advance.

Thanks again to everyone.
 
Top