I'm slowly getting crazy, I'm doing some measurements every ~30 minutes and recording them to 24lc512 .. I added the PCF8583 (as I had one lying around) in order to store the exact datetime when measurement was taken. As this 30min does not have to be too accurate (29-31) I used some internal counter (18f2550 running at 48MHz) that was incremented by the timer in order to trigger the measurement every ~30minutes but as I have the darn RTC on board and the darn thing should be able to sync the interrupt pin down on "alarm" but either the data sheet is not clear or nicotine deprivation I'm going trough now is doing something to my cognitive abilities...
In general, what I can see is that PCF8583's 2 ports are relevant to the problem:
CONFIG addr[ 0x00 ]
ALARM addr[ 0x08 ]
With regards to config (0) the relevant bits should be 0,1,2 where I have no idea of the 0,1 bits use (or they are just read only flags when the interrupt triggers); the bit 2 is alarm enable bit. So, I set the config bit to 0x04
ALARM config register (8), this get's tricky, I want interrupt every 30min so, the "timer vs clock" confuses me here. In general, I'd like timer (I do not care how much time it is, just trigger the interrupt every 30min) ... I was totally unable to get anything from here, all combinations I tried I only got 2 things
- int always high (pull up)
- int triggers every 1sec
Any ideas, how to make the darn thing trigger the int every 30min (or 15min or 45min) or this is not possible with PCF8583, I have too many devices on the i2c bus (4x24lc512, lcd, 5 sensors, pcf8583) and PIC is not "idle" during those ~30minutes, so if this RTC can trigger the int on 30min interval, great, if not, I'll continue the way I'm doing it now.
I'm not familiar with the PCF8583, but looking at the datasheet [https://www.nxp.com/acrobat_download/datasheets/PCF8583_5.pdf] I found section 7.7 which talks about the timer and how you can enable an alarm whenever the timer reaches a certain value. You can enable the timer alarm by setting bit 6 of the alarm control register (location 0x08), then set the timer resolution to minutes by making the 3 LSBs of memory location 0x08 into 011. So program a value of 01000011 = 0x83 into location 0x08, then program a value of 30 (0x1D) into location 0x0F to set the interval.
This above setup should cause bit 1 of the control/status register (0x00) to turn on every 30 minutes. Simply keep reading this value, when it changes to a 1, AND the control/status register with 0xFD to clear the flag again ready for the next 30 minutes. Don't forget to reset the timer (write 0x00 to location 0x07).
If you want to use the interrupt instead of reading the memory location 0x00, use the same setup of the timer as I put above but with location 0x08 set to 0xC3. This turns on the timer alarm interrupt. The reason you may have been getting interrupt high all the time is because it's an "active low" pin, i.e. when the interrupt triggers it goes LOW. So you need to check for a low signal on the interrupt to tell when your 30 minutes is up.
Note you do also need to set the alarm enable bit in the control/status register as you already talked about.
Hope that helps - just to reiterate, I've never seen the datasheet before
Sorry, I'm kinda frustrated as it didn't work from the beginning and it should.
I tried different values for config and for alarm registers (0 and 8) and all I got is
- nothing
- interrupt every 1 sec
If there is any combination you like me to try (just give me [addr, value] list) and I will try and let you know what is the output....
The "non clear" part of the ds is the alarm/timer config register (08) that is depending on the config (0) timer or alarm .. but again, /me not getting it ..
for starter, interrup every 2min would be cool (that is easy to test, 30min period is long to wait for) ... donno if there is anything else I can "add"
Sorry, I'm kinda frustrated as it didn't work from the beginning and it should.
I tried different values for config and for alarm registers (0 and 8) and all I got is
- nothing
- interrupt every 1 sec
If there is any combination you like me to try (just give me [addr, value] list) and I will try and let you know what is the output....
The "non clear" part of the ds is the alarm/timer config register (08) that is depending on the config (0) timer or alarm .. but again, /me not getting it ..
for starter, interrup every 2min would be cool (that is easy to test, 30min period is long to wait for) ... donno if there is anything else I can "add"
What happens with the values I described,
address [0x00] (status/control register) value 0x04
address [0x08] (alarm control register) value 0xC3
address [0x0F] (timer countdown) value 0x02 or however many minutes you want.
You need to reset the timer at the start,
address [0x07] (timer) value 0x00
Don't forget to do this and also write
address [0x00] value 0x04
ahydra, thanks big time, I finally nailed it (and still off nicotine sticks, still craving for them but ..).. and I must admit, without your help, I'd probably either gave up or reached for nicotine.
anyhow, the gotchas
1. timer countdown value must be BCD
2. alarm occurs only once, so you have to re enable it each time
It's not that the alarm turns itself off, it's that the interrupt flag sets. You need to clear the flag so that you can tell when the alarm has gone off again, which is why you need to reprogram that 0x04 into the status register.
i must use this RTC in my graduation project but i can't manage to set a daily alarm.
i've put 0x04 in 0x00 and 0b1001000 in 0x08, then i put my alarm in the required register (in BCD) but nothing happen when it should, /int stay high (pull-up)