PaulStoffregen / TimerOne

TimerOne Library with optimization and expanded hardware support
http://www.pjrc.com/teensy/td_libs_TimerOne.html
470 stars 209 forks source link

TimerOne issue in combination with BMP085 Adafruit driver #44

Open rbrunni opened 4 years ago

rbrunni commented 4 years ago

Hello Paul, I am using the TimerOne module in combination with the Adafruit BMP085 Sensor and driver. However when I run the call back function with the read out command for the sensor (bmp.readAltitude()), the program gets stuck. Any other command, e.g. a Serial.print command gets executed w/o any problems. I tried several different BMP085 drivers, all showing the same effect. Unfortunately, I am not able to debug the issue with the native Arduino IDE.
I am using an Arduino Uno and the IDE shows Version 1.8.13. The little program file is attached below. Any Idea? Rbrunni


include "TimerOne.h"

include

include

Adafruit_BMP085 bmp; // Define altitude variable volatile float Altitude;

void setup() { Serial.begin(9600); if (!bmp.begin()) { Serial.println("Could not find a valid BMP085 sensor, check wiring!"); while (1) {} }

Timer1.initialize(200000); Timer1.attachInterrupt(ReadSensorAlt); // Read the altitude value every 200ms }

void loop() {

Serial.print ("Altitude: ");
Serial.println (Altitude);  

}

void ReadSensorAlt(void) { // Read out of Sensor BMP085 does not work. Any other action works with the interrupt function Altitude = bmp.readAltitude(); }