Teensy 3.1 and si4432 (RF22) not working

Status
Not open for further replies.

lukas12p

Member
Hi,
I can't initialize si4432 (RF22) link connected by SPI to teensty 3.1 board using RadioHead library, but no problem when connected to Arduino board.
I am using Arduino IDE 1.6.6 + teensyduino 1.26 + RadioHead 1.50 http://www.airspayce.com/mikem/arduino/RadioHead/RadioHead-1.50.zip
Has anybody make it working recently?
Here is my code:
Code:
#include <ILI9341_t3.h>
#include <font_Arial.h>
#include <XPT2046_Touchscreen.h>
#include <SPI.h>
#include <RHMesh.h>
#include <RH_RF22.h>

#define RH_MESH_MAX_MESSAGE_LEN 100
#define TFT_VCC  6
#define RF_PIN  7
#define TS_CS  8
#define TFT_DC  9
#define TFT_CS 10
// MOSI=11, MISO=12, SCK=13

#define TS_MINX 150
#define TS_MINY 130
#define TS_MAXX 3800
#define TS_MAXY 4000

#define CLIENT_ADDRESS 1
#define SERVER1_ADDRESS 2
#define SERVER2_ADDRESS 3
#define SERVER3_ADDRESS 4

RH_RF22 driver(15,2);
RHMesh manager(driver, CLIENT_ADDRESS);

//XPT2046_Touchscreen ts(TS_CS);
ILI9341_t3 tft = ILI9341_t3(TFT_CS, TFT_DC);

void setup()
{
  Serial.begin(38400);
  pinMode(TFT_VCC, OUTPUT);
  analogWrite(TFT_VCC, 200);
  pinMode(2, INPUT);
  tft.begin();
  tft.setRotation(1);
  tft.fillScreen(ILI9341_BLACK);
  tft.setTextColor(ILI9341_YELLOW);
  tft.setFont(Arial_16);
  tft.setCursor(0, 0);
  tft.println("LCD OK");
  tft.setCursor(0, 18);
//  ts.begin();
  delay(1000);
  if (!manager.init())
    {
      tft.println("RF failed   !!!");
      Serial.println("RF failed   !!!");
    }
    else
    {
      tft.println("RF OK  :)");
      Serial.println("RF OK");  
    }
  driver.setTxPower(RH_RF22_TXPOW_2DBM);
}

uint8_t buf[RH_MESH_MAX_MESSAGE_LEN];

void loop()
{
  uint8_t len = sizeof(buf);
  uint8_t from;
  if (manager.recvfromAckTimeout(buf, &len, 3000, &from))
    {
      tft.fillScreen(ILI9341_BLACK);
      tft.setCursor(0, 80);
      tft.print("got reply from: ");
      tft.print(from, HEX);
      tft.println(": ");
      tft.println((char*)buf);
      Serial.println((char*)buf);
    }
  
  delay(10);
}
 
Does this radio use nIRQ?

I see you have "pinMode(2, INPUT)" in your code. Is that correct? Does RadioHead really use pin 2? Maybe it's trying to use interrupt #0, which would be pin 2 on Arduino Uno, but is pin 0 on Teensy 3.1.

Also, you might check whether the interrupt needs INPUT or INPUT_PULLUP.
 
Does this radio use nIRQ?
I see you have "pinMode(2, INPUT)" in your code. Is that correct? Does RadioHead really use pin 2? Maybe it's trying to use interrupt #0, which would be pin 2 on Arduino Uno, but is pin 0 on Teensy 3.1.
Also, you might check whether the interrupt needs INPUT or INPUT_PULLUP.

Yes, it uses nIRQ, pin is defined in: RH_RF22 driver(15,2); first is CS and second IRQ.
I tried it with pin 0 to be sure and also tried with INPUT_PULLUP, but still unsuccessful.
 
I have run RH with RadioHead and HopeRF and SiLabs radios that use the interrupt, on the T3.
Can you look with a scope or meter at the IRQ bit and see if it sticks at 0? If so, the ISR isn't getting invoked. It's a common problem.
 
I have run RH with RadioHead and HopeRF and SiLabs radios that use the interrupt, on the T3.
Can you look with a scope or meter at the IRQ bit and see if it sticks at 0? If so, the ISR isn't getting invoked. It's a common problem.
IRQ stays at 0 whet connected to T3 and it stays high when connected to Arduino board.
I am not sure if this matter but when compiling on T3 I get few warnings:
Code:
L:\ARDUINO\projekty\WS-client\WS-client.ino:8:0: warning: "RH_MESH_MAX_MESSAGE_LEN" redefined [enabled by default]
#define RH_MESH_MAX_MESSAGE_LEN 100
^
In file included from L:\ARDUINO\projekty\WS-client\WS-client.ino:5:0:
L:\arduino-1.6.6\hardware\teensy\avr\libraries\RadioHead/RHMesh.h:102:0: note: this is the location of the previous definition
#define RH_MESH_MAX_MESSAGE_LEN (RH_ROUTER_MAX_MESSAGE_LEN - sizeof(RHMesh::MeshMessageHeader))
^
L:\arduino-1.6.6\hardware\teensy\avr\libraries\RadioHead\RHSoftwareSPI.cpp: In member function 'virtual void RHSoftwareSPI::begin()':
L:\arduino-1.6.6\hardware\teensy\avr\libraries\RadioHead\RHSoftwareSPI.cpp:114:13: warning: variable 'delayCounts' set but not used [-Wunused-but-set-variable]
uint8_t delayCounts;
^
L:\arduino-1.6.6\hardware\teensy\avr\libraries\RadioHead\RH_ASK.cpp: In member function 'void RH_ASK::timerSetup()':
L:\arduino-1.6.6\hardware\teensy\avr\libraries\RadioHead\RH_ASK.cpp:161:14: warning: unused variable 'nticks' [-Wunused-variable]
uint16_t nticks; // number of prescaled ticks needed
^
L:\arduino-1.6.6\hardware\teensy\avr\libraries\RadioHead\RH_ASK.cpp:162:13: warning: unused variable 'prescaler' [-Wunused-variable]
uint8_t prescaler; // Bit values for CS0[2:0]
^
but the same code compiles without warnings on Arduino board.
 
The compiler messages are all warnings, not errors. Due to the mesh protocol probably hasn't been built for the T3 case.

IRQ should be 1 except for microseconds or less of 0 when waiting for the ISR to run. If the IRQ is 1 briefly after a reset, as it should be, then when the radio asserts IRQ and it sticks "true" at 0, then the ISR did not get dispatched. The ISR function would be in the C++ class constructor as I recall, and perhaps that's not correct, and the T3 is doing a wild jump when the IRQ occurs.
 
I have checked again with my slow voltmeter: IRQ pin on T3 is high just after restart then goes low when init() occur and stays low. On Arduino it stays high all time.
Do You know any solution or should I ask on RadioHead group? I am not good at programing to find the way out by myself.
 
Status
Not open for further replies.
Back
Top