attachInterrupt() not working for RISING and FALLING edges.

Hello.

I'm using Arduino Due for reading digital calipers, however I'm not able to read the data properly, because
attachInterrupt() is only working at HIGH levels of the clock signal, it's not working for RISING,FALLING and LOW.
Anybody can help me to know why attachInterrupt() is not working for RISING and FALLING edges but working
for HIGH ? it's really important to have these two options in order to overcome the problem of glitches and identify
the start and the end of each set of data which is 24 bits with a start bit of 52 microseconds of length.
Has anyone used Arduino for reading digital calipers before like this example http://nut-bolt.nl/2012/reading-digital-calipers-with-an-arduino/ ?
The code in this example is full of bugs, but I really need help from some one who has done similar job, as I'm not
too experienced with Arduinos but the job needs to be done

Suggest you attach your code, and a description/drawing of your hardware, because there are different sorts of interrupt available on different pins.

PeterH:
Suggest you attach your code, and a description/drawing of your hardware, because there are different sorts of interrupt available on different pins.

Hello.

Thanks for your reply.

There is a mixed Signal oscilloscope (Tektronix),Digital caliper, and small amplifying Circuit consisting of one BJT PNP transistor (Common Collector) with several resistors to amplify the signal from 1,5v to 3,3v so the Arduino Due can read it through the Digital pins number 2 and 3,they both require 3,3v. The Data signal is connected to Digital Pin number 3, the clock signal is connected to Digital pin number 2.

This is DRO output format
2x 24bit serial data (Abosulte poistion; Relative position)
Data is LSB first, 2's complement
0x5000 (20480) count/inch or 806.299 counts / mm
clock: 13us /bit == 76.92KHz
data output rate = 3.125 Hz
Start bit length = 52.2 uS

And I also attached an image of the data and clock signals captured on Oscilloscope's Screen, though it doesn't include
the inverted and amplified Digital and Clock Signals.

Arduino DUE should read data signal at each falling edge of the clock signal, it should also confirm that the read
data was accurate at the rising edge, and if the clock signal goes low for 24 times it means that the data set is complete and ready to be sent to the pc via Serial port, there is also start bit of 52,2 uS length that should be identified and not confused with other bits.
This is the code after I modified it and had to cancel the interrupts at Rising and falling edge of the clock signal and got restricted to HIGH level interrupt.

int CAL_CLK =2;
int CAL_DATA =3;
unsigned long now;
unsigned long lastInterrupt; 
volatile long finalValue; //
volatile long value;
int bits=0; // Number of received bits
volatile long data;



void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(CAL_CLK, INPUT);  // Clock pin = 2
  pinMode(CAL_DATA, INPUT); // Data pin = 3
 
  attachInterrupt(0, dataReceived, HIGH);
}

void dataReceived() {
 now=millis();
if((now-lastInterrupt)>150)    //if more than 150 milliseconds have passed since the first interrupt print the value
 
 {
   
   Serial.println(finalValue,HEX);
   
 }

else{
data = digitalRead(CAL_DATA);
 if(bits==0)
 {
   value=0;
   lastInterrupt=now;  To measure the length of time between the first and current interrupt
 } 
 if(bits<16) // the first 16 bits indicate the value of the data set
 {
   if(data==0)
   {
   value |= 1<<(23-bits);
   }
 }

   
 if(bits==20) // if 21st fit (sign bit) is 1,then invert the value and add 1 (second complement)
  {
    if(data==1)
  {
    value = (~value)+1;
   
    
  }
  }
  
  if(bits==23){  
    finalValue=value;
    bits=0; //if 24 bits have received , set the finalValue to be sent and start again.
  }
 bits=bits+1;
 }
  
  
}


void loop() {
  // put your main code here, to run repeatedly:


}

Also I'v been told that the data output rate is 3.125 Hz, which means that 3 sets of 48 bits is sent every second,so for 24 bits of data arduino should send every 150 milliseconds approximately, but its not working, I'm having to disable the timer removing the first three lines of dataReceived() function and put Serial.println(finalValue,HEX); inside if(bits==23){} instead.

Moderator edit: code tags { sigh }

Don't do Serial output inside an interrupt handler - it can lead to the Arduino locking up. Similarly, don't call delay().

Is "HIGH" even a sensible parameter for an call to attachInterrupt( ) ? What do you expect it to do ? The normal keywords are rising, falling , or change. How is being HIGH an event ?

How is being HIGH an event ?

Its an option that only the Due has.

Parameters

interrupt: the number of the interrupt (int)
pin: the pin number (Arduino Due only)
ISR: the ISR to call when the interrupt occurs; this function must take no parameters and return nothing. This function is sometimes referred to as an interrupt service routine.

mode:
defines when the interrupt should be triggered. Four contstants are predefined as valid values:
LOW to trigger the interrupt whenever the pin is low,
CHANGE to trigger the interrupt whenever the pin changes value
RISING to trigger when the pin goes from low to high,
FALLING for when the pin goes from high to low.

The Due board allows also:
HIGH to trigger the interrupt whenever the pin is high. (Arduino Due only)

Using a steady HIGH or LOW as an interrupt trigger is almost always problematic unless the ISR is able to do something to remove the external trigger level back to it's inactive state, it just adds complexity. Change, rising, falling are the useful trigger states.

Can you explain what you are trying to do?

And can you explain what you would like to happen when the interrupt is triggered?

In both cases without using computer code in the explanations.

My instinct is that your ISR is much too complicated - and, as someone else said, Serial.print() and delay() caan't be used.

...R