Project

General

Profile

JeeNode Micro (V1) + Gravity Plug problem

Added by gv about 7 years ago

I returned to a JeeNodeMicro project, where I want to read out data from the gravity plug and send it with the RFM12B. Everything works fine until I try to read data from the BMA020 (see last line of the demo code: const int* p = sensor.getAxes();) I even tried different different gcc compiler version (see http://forum.jeelabs.net/node/1574.html) I would appreciate any help!

#include  
MilliTimer sendTimer; 
char payload[] = "Hello from JeeNodeMicro!"; 
PortI2C myBus(1); 
GravityPlug sensor(myBus); 

void setup () { 
  Serial.begin(38400); 
  rf12_initialize(1, RF12_868MHZ,33); 
} 

void loop () { 
  rf12_recvDone(); 
  sendTimer.poll(1000); 
  if (rf12_canSend()) { 
    rf12_sendStart(0, payload, sizeof payload); 
  } 
  const int* p = sensor.getAxes(); // causes JeeNodeMicro to crash
}

Replies (7)

RE: JeeNode Micro (V1) + Gravity Plug problem - Added by JohnO about 7 years ago

What are you using the serial initialise for?

Serial.begin(38400);

I have used software serial on the Micro V1 and it works fine but I use:

#include 
.
.
    pinMode(rxPin, INPUT);
    pinMode(txPin, OUTPUT);

    // set the data rate for the NewSoftmymySerial port
    mySerial.begin(19200);

JeeNode Micro (V1) + Gravity Plug problem - Added by martynj about 7 years ago

gv,  if you comment out all the RFM12B stuff, can you interact with the g- plug successfully?

RE: JeeNode Micro (V1) + Gravity Plug problem - Added by gv about 7 years ago

@JohnO, I am not using software serial. I have sent debug information via RFM12B. (Sorry, but the Serial.begin(38400) statement is misleading - I forgot to remove it from the code for the regular JeeNode).

martynj, at the moment I cannot interact with the JeeNodeMicro when commenting out the RFM12B stuff. Do you think of some interference between the RFM12B and software I2C used for communication with the BMA020 gravity sensor? I thought that there might be some compiler and/or memory problems.

RE: JeeNode Micro (V1) + Gravity Plug problem - Added by JohnO about 7 years ago

I’m a little surprised that it compiled with the serial statement in place. Are you sure that your IDE is setup correctly for the Tiny CPU.

What happens when you run without it?

RE: JeeNode Micro (V1) + Gravity Plug problem - Added by martynj about 7 years ago

gv, as a hardware man, I tend to look there first.  The moment you set up the interrupt service routine for the RFM12B (which of course takes SPI commands) you seem to die.  So I would look carefully at pin/interrupt allocation etc.
If you can’t get the soft serial to work, try plugging a couple of test LED/resistors on to spare DI/O lines and use that as a debug tool to show where you have reached in the code before the hang.  (4 possible states to display - some pauses and pin set/unset combinations).

RE: JeeNode Micro (V1) + Gravity Plug problem - Added by gv about 7 years ago

martynj, for debugging I use now the button plug with 2 LEDs. It was so simple - thank you for the advice.
The good news: The JeeNode Micro doesn’t hang up.
The bad news: The RFM12B doesn’t work as soon as I add const int* p = sensor.getAxes() to the code. And the gravity sensor return –1, that’s what happens on a regular JeeNode when I forgot to connect the sensor. So I assume the sensor does not work, too. Next I will try to remove all RMF12B, Serial and Timer stuff from the code and I hope the gravity plug will work.

@JohnO, I removed all Serial.x statements from the code. I even removed the Timer (do they depend on interrupts?). No change. To overcome the problem described here I have tried different gcc Version before, so the Arduino system may be a bit chaotic, but everything works fine.

Can you point me to some beginner information about interrupts and memory allocation on the ATTINY?

partially solved: JeeNode Micro (V1) + Gravity Plug problem - Added by gv almost 7 years ago

Problem partially solved: When I use the Jeelib update from March the gravity plug works fine when I attach the plug to Port 1, but initialize Port 2: PortI2C myBus(2) (RFM12B works as well as PWM via PA7; I’m still working with the JNM version 1)

    (1-7/7)