T3 hangs with SD & interrupts

Status
Not open for further replies.

pixelk

Well-known member
[Solved] T3 hangs with SD & interrupts

Hello,

I have a fairly complex (for me) project : make a fully automated astronomy photo mount.
This means :
- A teensy (3.0, may be upgraded to a 3.1 if needed - I already have them)
- A Sparkfun LSM9DS0 IMU Breakout - 9DoF wired in I2C mode (official library)
- An Adafruit Graphic ST7565 Negative LCD (128x64) with RGB backlight bit-banged (official library)
- An Adafruit MicroSD card breakout board+ accessed though SPI (Teensyduino SD library)
- A Rotary Encoder - Illuminated (RGB) replaced by a simple push button for my tests
- A 32Khz crystal & 3V battery for the RTC

Everything works fine together until I try to access the SD after an interrupt (needed by the rotary encoder). The teensy locks up and I need to reset it to reboot it or upload a new sketch.
Everything works fine if I remove the interrupt (not an option for my project) or remove the file write (not an option during development, maybe in the final project).
I tried the "alternative" SDFat library, but with the same result.

IMG_2014-05-15_21-48-59_cr800_3FC4ECCF.jpg

Here is my sketch

If I remove the comment at line 143, I can triger the bug at will by a press on the button.

I tried everything I could think of. I found some mention of hangs with SD and interrups, but no solution so far.

Any idea would be welcome.
 
Last edited:
Thank you for the advice, I removed them, but the board still stops working after the fuirst use of the interrupt.
 
Ahh. Your EncoderSwitch interrupt routine is also waiting for the button to be released. Also not a good thing to do in an interrupt routine.
Leave "EncoderPressed = true;" in the routine but move the rest into the loop() function where you check for EncoderPressed.

Pete
 
Status
Not open for further replies.
Back
Top