How do you check if Teensy 2.0 INT6 (pin 24) works?

Status
Not open for further replies.

JLu

New member
I am currently working on a Teensy 2.0 project that requires me to use the following:
SS SCLK MOSI MISO (0,1,2,3) - for an Adafruit RFM95W LoRa module - https://learn.adafruit.com/adafruit-rfm69hcw-and-rfm96-rfm95-rfm98-lora-packet-padio-breakouts
SCL SDA (5,6) - for an Adafruit SHT31-D sensor - https://learn.adafruit.com/adafruit-sht31-d-temperature-and-humidity-sensor-breakout
RX TX (7,8) - for an Adafruit PM2.5 Sensor - https://learn.adafruit.com/pm25-air-quality-sensor/arduino-code

Now for my LoRa module to work, I needed an INT pin and based on the datasheet, pins 5,6,7,8 and 24 are my only choices.
Now 5, 6, 7 and 8 are already being used and my only choice would be pin 24.

I have tested each INT pin (5, 6, 7 and 8) on my LoRa module and it works.
Upon testing pin 24, I can do a digital High/Low on it. But when I use it for my LoRa it won't respond.

I'm using the RadioHead Library on the Arduino IDE and this is how I setup the pin
RH_RF95 rf95(0,24); // param1 is SS pin and param2 is the INT pin

Is there any special setting to make pin 24 work as an INT pin?
 
It appears that Teensy 2 core does not support attachInterrupt() on pin 24. I'll take a look at how hard it will be to fix ....
 
OK, attached is hacked WInterrupts.c Use it to replace hardware/teensy/avr/cores/teensy/WInterrupts.c
You must call attachInterrupt() with 24 as the pin. (digitalPinToInterrupt(), pin2int(), and detachInterrupt() have NOT been fixed).
I did a quick test jumpering a PWM pin (analogWrite(10,128)) to pin 24 and counting ticks in the isr function.
 

Attachments

  • WInterrupts.c
    3.7 KB · Views: 68
So I tried using "RH_RF95 rf95(0,24)" and it still doesn't work.
So you mentioned that I should use attachInterrupt(pin,ISR,mode) for it to work properly.
I'm not using the ISR because RH_RF95 is just a constructor for me to use and i guess it won't be fixed until the whole thing gets sorted out?

So here's actually how the first part of my code looks like in case you're wondering how I use it:

Code:
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <Arduino.h>
#include <EEPROM.h>
#include <RHRouter.h>
#include <RHMesh.h>
#include <RH_RF95.h>
#include "Adafruit_SHT31.h"
#include <AltSoftSerial.h>

#define N_NODES 2

uint8_t nodeId;
uint8_t routes[N_NODES]; // full routing table for mesh
int16_t rssi[N_NODES]; // signal strength info
float ppm[12];


AltSoftSerial pmsSerial;
Adafruit_SHT31 sht31 = Adafruit_SHT31();
LiquidCrystal_I2C lcd(0x27, 16, 2);

// Singleton instance of the radio driver
RH_RF95 rf95(0,24);

// Class to manage message delivery and receipt, using the driver declared above
RHMesh *manager;

// message buffer
char buf[120];

const long interval = 1000;
unsigned long previousMillis = 0;

int freeMem() {
  extern int __heap_start, *__brkval;
  int v;
  return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
}

struct pms5003data {
  uint16_t framelen;
  uint16_t pm10_standard, pm25_standard, pm100_standard;
  uint16_t pm10_env, pm25_env, pm100_env;
  uint16_t particles_03um, particles_05um, particles_10um, particles_25um, particles_50um, particles_100um;
  uint16_t unused;
  uint16_t checksum;
};

struct pms5003data data;

...
void setup(
manager = new RHMesh(rf95, nodeId);
// fails initialization when rh95 cannot use pin 24 as intterupt
  if (!manager->init()) {
    Serial.println(F("init failed"));
  } else {
    Serial.println("done");
  }
) {...}
void loop() {...}
 
Status
Not open for further replies.
Back
Top