arduino-LoRa
arduino-LoRa copied to clipboard
OnReceive and OnTxDone Interrupts not working ATtiny84
I used the LoRa Receiver Callback example and changed only the operating frequency and pins using setPins shown in the code below. I connected DIO0 to pin PA3/PCINT3, SS to PA0/PCINT0 and RESET to PB3/PCINT11.
I hooked up an oscilloscope to the DIO0 pin and can see it get pulled high the moment a message is received, however the onReceive callback is never called. I can confirm this by hooking the oscilloscope to the TX/PA1/PCINT1 pin. I have tried other things like driving a pin high to light up an LED ect, but nothing seems to work.
I am not sure if the ATtiny 84/85 are supported at all, but everything else seems to work fine except this. I really want to get it working if possible 🥲.
#include` <SPI.h>
#include <LoRa.h>
#ifdef ARDUINO_SAMD_MKRWAN1300
#error "This example is not compatible with the Arduino MKR WAN 1300 board!"
#endif
#define SS 0
#define DIO0 3
#define RESET 11
void setup() {
Serial.begin(9600);
while (!Serial);
Serial.println("LoRa Receiver Callback");
LoRa.setPins(SS, RESET, DIO0);
if (!LoRa.begin(433E6)) {
Serial.println("Starting LoRa failed!");
while (1);
}
// Uncomment the next line to disable the default AGC and set LNA gain, values between 1 - 6 are supported
// LoRa.setGain(6);
// register the receive callback
LoRa.onReceive(onReceive);
// put the radio into receive mode
LoRa.receive();
}
void loop() {
// do nothing
}
void onReceive(int packetSize) {
// received a packet
Serial.print("Received packet '");
// read packet
for (int i = 0; i < packetSize; i++) {
Serial.print((char)LoRa.read());
}
// print RSSI of packet
Serial.print("' with RSSI ");
Serial.println(LoRa.packetRssi());
}
As far as I can see, in AtTinyCore, digitalPinToInterrupt will return NOT_AN_INTERRUPT for any pin except CORE_INT0_PIN, which PIN_B1.
#define CORE_INT0_PIN PIN_B1
#define digitalPinToInterrupt(p) ((p) == CORE_INT0_PIN ? 0 : NOT_AN_INTERRUPT)
So by using PA3 your request to attach an interrupt is probably kicked to the curb. Try to use PIN_B1.