0
\$\begingroup\$

I have PCF8563 WAVESHARE board connected to DIGISPARK via I2C. Here is the code:

    #include "Rtc_Pcf8563.h"

/* Demonstration of Rtc_Pcf8563 Set Time. 
 * Set the clock to a time then loop over reading time and 
 * output the time and date to the serial console.
 *
 * I used a RBBB with Arduino IDE, the pins are mapped a 
 * bit differently. Change for your hw
 * SCK - A5, SDA - A4, INT - D3/INT1
 *
 * After loading and starting the sketch, use the serial monitor
 * to see the clock output.
 * 
 * setup:  see Pcf8563 data sheet.
 *         1x 10Kohm pullup on Pin3 INT
 *         No pullups on Pin5 or Pin6 (I2C internals used)
 *         1x 0.1pf on power
 *         1x 32khz chrystal
 *
 * Joe Robertson, jmr
 * orbitalair@bellsouth.net
 */ 

#include <TinyPinChange.h>
//#include <Wire.h>


//init the real time clock
Rtc_Pcf8563 rtc;
uint8_t VirtualPortNb;
volatile bool flag =0 ;

void setup()
{

  VirtualPortNb = TinyPinChange_RegisterIsr(3,  wakeUpRTC);

  pinMode(3, INPUT);           // set pin to input
  pinMode(1, OUTPUT);

  //clear out the registers
  rtc.initClock();
  //set a time to start with.
  //day, weekday, month, century(1=1900, 0=2000), year(0-99)
  rtc.setDate(27, 1, 5, 0, 19);
  delay(100);
  //hr, min, sec
  rtc.setTime(19, 43, 45);

  rtc.setAlarm( 19, 44, 99, 99 );

  for( int i=0; i<3; i++ ){
      digitalWrite( 1, 1);
      delay(600);
      digitalWrite( 1, 0);
      delay(600);
  }

  TinyPinChange_EnablePin( 3 );
}

void loop(){
  if (flag==1){
    flag = 0;
    for( int i=0; i<10; i++ ){
      digitalWrite( 1, 1);
      delay(300);
      digitalWrite( 1, 0);
      delay(300);
    }
  }
}

void wakeUpRTC(){
  flag = 1;
}  

schematic

simulate this circuit – Schematic created using CircuitLab

There are 10k pullup resistors on SCL, SDA and INT pins. INT is Open Drain

Problem is that ATTINY does not detect external interrupt. Strange thing is that when I measure voltage on INT pin there is 3V instead od 5.2V (VCC). When I run very similar code on Arduino UNO, everything works perfect.

Any ideas?

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.