-
-
Notifications
You must be signed in to change notification settings - Fork 35
attachInterrupt() always pulls pin HIGH #77
Comments
After further investigation this is more serious than I thought. The following code works perfectly well on AVR devices (tested on Nano Every and Duemilanove), but fails on the BLE33: const uint8_t buttonPin = 2;
const uint8_t testPin = A3;
volatile boolean newPress = false;
void setup(){
pinMode(testPin, OUTPUT);
digitalWrite(testPin, HIGH);
attachInterrupt(digitalPinToInterrupt(buttonPin), buttonISR, RISING);
}
void loop(){
if(newPress){
newPress = false;
}
void buttonISR(void){
newPress = true;
} For both the Nano Every and Duemilanove, On the BLE33, |
This is turning out to be a fatal issue for something I'm developing. Does the solution lie in mbed::InterruptIn* irq = new mbed::InterruptIn(digitalPinToPinName(interruptNum)); |
I have also tested this and can confirm that only setting up the Pin mode works correctly as expected on Arduino Nano 33 BLE Sense. However, for any attach Interrupt command, the interruptPin is then pulled high. I would expect that calling attachInterrupt should not change the already set pinMode. Perhaps more troubling, to me at least, is that asserting an interrupt condition on the hardware pin does not trigger the interrupt call in software; rather, it crashes the Arduino Nano 33 BLE Sense requiring a hard reboot. Specifically this test interrupt only generates a response by pulling the interruptPin LOW, which crashes the Arduino Nano 33 BLE Sense. Tested using Arduino 1.8.12 with an Arduino Nano 33 BLE Sense with board manager current as of today. |
So I've been trying to convince myself for the past 3 days that this is a hardware or software fault on my side. I've rebuilt my circuit over again and tried every trick I know. The button example I gave above was just a basic test for what I'm doing - I'm actually communicating with an interrupt-triggered precision ADC over SPI. My library and code work absolutely fine using the exact same pinouts on a Even using a 3.3V -> 5V shifter on SCLK/MISO/MOSI/!CS (the ADC is 5V tolerant) still works perfectly on the But the exact same code with the exact same pinout and the exact same circuit fails on the @facchinm and others - can we ask that you address this issue as a matter of urgency? Being unable to use interrupt-triggered reads of an SPI ADC is a very serious flaw in your |
@rmlearney-digicatapult This is unlikely to be caused by your or my improper/proper use of the software or hardware. I have just opened a brand new NANO 33 BLE and confirmed the exact same response without attaching any hardware other than a jumper wire to test the pin voltage and interrupt behavior. The interrupt pin is pulled high even if the pin is not previously defined; so the following code will reproduce this at will; and crash the NANO 33 BLE when the pin is externally pulled LOW.
This happens on any input capable pin and any variety of attachInterrupt as noted previously. Note that this program is just a bare minimum to compile and reproduce the error. Edited : Sorry, the CRASH only happens with a valid function to call. The pin pulling high happens in any case. |
@chibiconsulting the crash is due to Serial.print being called in an interrupt context, while the pullup bug is going to be solved by a modified version of #31 that will be merged soon. |
@facchinm Thank you, that works much better for me. |
I have the same issue with NANO 33 SENSE! spending 3 days to figure it with interrupts pin is HIGH |
Hi,
I'm trying to set an interrupt based on detecting a RISING edge using the BLE33. However, the pin reads HIGH after startup. Same happens with
pinMode(buttonPin, INPUT_PULLDOWN)
followed byattachInterrupt()
. It's theattachInterrupt()
that pulls it HIGH.Am I doing something wrong or misunderstanding what's going on here?
The text was updated successfully, but these errors were encountered: