Real Time Clock Timing

Here is a picture of signals between motherboard and rtc clock. RTC uses Intel timing protocol. Pulse duration is about 1µs and time between pulses are about 24µs. AS means Address Select. It functions like clock signal. When DS is low then motherboard wants to read rtc and when RW is low motherboard wants to write to rtc memory. Data protocol is same as generic RAM memory. All this is valid only if MOT pin is connected low. Otherwise Motorola timing is used and it is completely different.

Simple Four Channel Logic Analyzer/Oscilloscope

This simple program uses four pins of Arduino analog port. On version 0.3 there is about 4ms/division and about 400ms delay between measurements. Also measurements is made only when there is some signal on inputs. Old version 0.1 picture is below.

Version 0.2 image.

Version 0.3 image.

New version 0.3 code.

#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9340.h"

#define _cs 10
#define _dc 9
#define _rst 8

Adafruit_ILI9340 tft = Adafruit_ILI9340(_cs, _dc, _rst);

volatile boolean measure = false;

void pciSetup(byte pin) {
  *digitalPinToPCMSK(pin) |= bit (digitalPinToPCMSKbit(pin));  // enable pin
  PCIFR  |= bit (digitalPinToPCICRbit(pin)); // clear any outstanding interrupt
  PCICR  |= bit (digitalPinToPCICRbit(pin)); // enable interrupt for the group
}

void setup() {
  
  pciSetup(A0);
  pciSetup(A1);
  pciSetup(A2);
  pciSetup(A3);
  
  tft.begin();
  tft.setRotation(3);
  tft.fillScreen(ILI9340_BLACK);

  tft.setTextColor(ILI9340_YELLOW);
  tft.setTextSize(2);

  tft.drawFastHLine(0,(tft.height()/5)*1, 320, tft.Color565(30,30,30));
  tft.drawFastHLine(0,(tft.height()/5)*2, 320, tft.Color565(30,30,30));
  tft.drawFastHLine(0,(tft.height()/5)*3, 320, tft.Color565(30,30,30));
  tft.drawFastHLine(0,(tft.height()/5)*4, 320, tft.Color565(30,30,30));
}

int xpos = 0;

  int pin0_state[161];
  int pin1_state[161];
  int pin2_state[161];
  int pin3_state[161];

void loop() { 
  if(!measure) return;
  measure = false;
  
  unsigned long start = 0;
  unsigned long end_time = 0;

  pin0_state[0]=0;
  pin1_state[0]=0;
  pin2_state[0]=0;
  pin3_state[0]=0;

  start = micros();
  for(int i = 0; i < 160; i++) {
    pin0_state[i] = analogRead(0);
    pin1_state[i] = analogRead(1);
    pin2_state[i] = analogRead(2);
    pin3_state[i] = analogRead(3);
  }
  
  end_time = micros() - start;

  for(int i = 0; i < 320; i=i+2) {
    //erase
    if(!(i%20)) tft.drawFastVLine(i, 17, tft.height(), tft.Color565(30,30,30));
    else tft.drawFastVLine(i, 17, tft.height(), ILI9340_BLACK);
    
    tft.drawPixel(i, ((tft.height()/5)*1)-(pin0_state[i/2]/32), ILI9340_YELLOW);
    tft.drawPixel(i, ((tft.height()/5)*2)-(pin1_state[i/2]/32), ILI9340_RED);
    tft.drawPixel(i, ((tft.height()/5)*3)-(pin2_state[i/2]/32), ILI9340_GREEN);
    tft.drawPixel(i, ((tft.height()/5)*4)-(pin3_state[i/2]/32), ILI9340_CYAN);
  }

  tft.setCursor(0, 0);
  tft.fillRect(0, 0, 320, 17, ILI9340_BLACK);
  tft.print((end_time/1000)/16); //one div is X milliseconds
  tft.print("ms/div, int:");
  tft.print((micros() - start)/1000); //interval time
}

ISR (PCINT1_vect) {
  measure = true;
}

Here is simple analog datalogger code. Analog value can be between zero and 127. It is viewable with external software.

void setup() {
pinMode(A3, INPUT); 
pinMode(A2, INPUT); 
pinMode(A1, INPUT); 
pinMode(A0, INPUT);

Serial.begin(9600);
}

void loop() {

  char testi[101] = {};
  char testi1[101] = {};
  char testi2[101] = {};
  char testi3[101] = {};
  
  for(byte i=0; i<100; i++) {
    int temp0 = analogRead(0);
    int temp1 = analogRead(1);
    int temp2 = analogRead(2);
    int temp3 = analogRead(3);
    testi[i] = (temp0/8)-1;
    testi1[i] = (temp1/8)-1;
    testi2[i] = (temp2/8)-1;
    testi3[i] = (temp3/8)-1;
  }

  Serial.println(testi);
  Serial.println(testi1);
  Serial.println(testi2);
  Serial.println(testi3);
  Serial.println("new");
}

Even simpler version that outputs data in CSV format.

void setup() {
pinMode(A3, INPUT);
pinMode(A2, INPUT);
pinMode(A1, INPUT);
pinMode(A0, INPUT);

Serial.begin(9600);
}

void loop() {

  char text[101] = {};
  
  for(byte i = 0; i < 93; i = i + 8) {
    int temp0 = analogRead(0);
    int temp1 = analogRead(1);
    int temp2 = analogRead(2);
    int temp3 = analogRead(3);
    text[i] = (temp0/8)-1;
    text[i+1] = ',';
    text[i+2] = (temp1/8)-1;
    text[i+3] = ',';
    text[i+4] = (temp2/8)-1;
    text[i+5] = ',';
    text[i+6] = (temp3/8)-1;
    text[i+7] = '\n';
  }
  Serial.print(text);
}

Now it’s possible to save and study data right from RTC circuit and motherboard.