EmbDev.net

Forum: µC & Digital Electronics Interrupt PIN Bouncing


von Manuel M. (muella91)


Attached files:

Rate this post
useful
not useful
Hello,

I am posting this in this category because I think its a hardware/ 
electronic problem.

short summary:
I am using Raspberry Pi 3 with a ADXL345 Accelerometer. I want to read 
data only if the DATA_READY bit is set and a Interrupt is thrown.
The data sheet of the sensor says: If new data is ready, the Interrupt 
is thrown and sets the PIN (which is mapped to the interrupt) to high. 
Its high until I read data from the data registers. If new accel data is 
available, the interrupt stays high (dont jumps to low and high again).
I connected the INT1 PIN with PIN17 of my GPIO.

As you see in the attachment, the four PINS on the top are the CS, MISO, 
MOSI and the SCLK. The lower one is PIN17, which is the interrupt. As 
you see it jumps up and down, changes its state every 450 us. (my 
sampling rate is just 0,78 Hz).

I think there no problem with my code, but I will post it below.
For the SPI comunication I am using the spidev.h and ioctl.h. For the 
interrupt handler I am using the wiringPi package, which works fine 
(obviously it calls my ISR way to often).

Thank you very much in advance.

Code is in the attachment.

: Edited by User
von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
useful
not useful
Manuel M. schrieb:
> I think there no problem with my code, but I will post it below.
I think you better done this way:
1
Reply
2
Rules — please read before posting
3
    Post long source code as attachment, not in the text

> As you see it jumps up and down, changes its state every 450 us. (my
> sampling rate is just 0,78 Hz).
What happens when you don't read the sensor?

von Manuel M. (muella91)


Rate this post
useful
not useful
Lothar M. wrote:
> I think you better done this way:Reply
> Rules — please read before posting
>     Post long source code as attachment, not in the text

Thank you for your answer.
I attached the code.

Lothar M. wrote:
> What happens when you don't read the sensor?

Actually I am not reading it right now. The sensor measures but I am not 
reading the data.

If I disable the interrupts (cli()) or go in STAND_BY mode, the 
Interrupt PIN is at low (and stays low).

If I try to read data if a interrupt is thrown, what happens is:
Until my programm reads the data (in the ISR), the Interrupt jumped 
already up and down several times. So my ISR is called at least 2-3 
times until I print out the measurements.

von Manuel M. (muella91)


Attached files:

Rate this post
useful
not useful
Here you see how I tryed to sample with 25 Hz. I used a stopwatch to 
measure the time. I stopped it after 250 samples, so normally after 10 
seconds. But the stopwatch measured 9,2 seconds. Thats because the 
interrupt was thrown too often (and counted the interrupt counter).

Maybe on the picture it looks like it, but the clusters happens also 
during the programm, not only at the beginning.

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.