DS3234 - disable alarms

I'm using alarms successfully, but now there are times when I need to turn them off. Here's a little info:

/* control register 0Eh/8Eh
bit7 EOSC   Enable Oscillator (1 if oscillator must be stopped when on battery)
bit6 BBSQW  Battery Backed Square Wave
bit5 CONV   Convert temperature (1 forces a conversion NOW)
bit4 RS2    Rate select - frequency of square wave output
bit3 RS1    Rate select
bit2 INTCN  Interrupt control (1 for use of the alarms and to disable square wave)
bit1 A2IE   Alarm2 interrupt enable (1 to enable)
bit0 A1IE   Alarm1 interrupt enable (1 to enable)
*/

Normally, I do one of these three:

  DS3234_set_creg(cs, DS3234_INTCN | DS3234_A1IE);   // activate Alarm1
  DS3234_set_creg(cs, DS3234_INTCN | DS3234_A2IE);  // activate Alarm2
  DS3234_set_creg(cs, DS3234_INTCN | DS3234_A1IE | DS3234_A2IE) ; //activate both alarms

So to have neither alarm go off, would this be what I use:

  DS3234_set_creg(cs, DS3234_INTCN);  //turn off both alarms

I just barely understand these bit things, but I think this will remove the alarm enable flags, correct?

I'd need a copy of whatever library you are using or at least the implementation of the DS3234_set_creg command to tell you. I don't know if using that function with 0's will work or if there is another clear_creg function to clear bits.

  DS3234_clear_a1f(cs);   //clear the alarm1 flag
  DS3234_clear_a2f(cs);  // clear the alarm2 flag

I use these to clear the flags that were triggered by the alarm. Let me find the library...

This is the library I use:
DS3234 Library

On the same topic regarding my lack of bit knowledge, I just ran into another condition I've never had before. I need to activate alarm 2, but also keep alarm 1 in whatever state it is- whether or not it's activated or not activated. Is this possible?

OK, so set_creg just sets the creg to whatever bit pattern you give it. If you want to turn everything off, and you don't need any bits in the creg set, then you can just set it to 0.

If you only want to turn off one bit in the creg, then you'll have to get the creg first so you can se tit back like it was. Unfortunately, they don't seem to have included any function for doing that.

Ok, so then from this line: bit2 INTCN Interrupt control (1 for use of the alarms and to disable square wave)

This will make alarms activated (as opposed to square wave output), but neither of them will be turned on?

DS3234_set_creg(cs, DS3234_INTCN);

No it would set INTCN flag to 1 (square wave interrupt disabled and alarms interrupt enabled if at least one alarm is also enabled), so as you don't set the A1IE and A2IE flags, the alarms are disabled.

Yes it's weird that there isn't a DS3234_get_creg function. Here is one, should work:

uint8_t DS3234_get_creg( const uint8_t pin )
{
    return DS3234_get_addr( pin, 0x0E );
}

You should use this function so that you don't mess the other flags.

Thanks. I'll test out that to see how to read the current state of the bits.