Project

General

Profile

RF12Demo with Moteino Mega1284P

Added by JohnO over 4 years ago

I understand that we ought to use git to track development issues. At the moment I don’t see any options to add new issues using the web access to git. Can anyone indicate how new issues can be added to git?

I aquuired a Moteino Mega recently as I wanted more eeprom and RAM. I have attempted to adjust RF12Demo to accommodate the new processor with a partial success. The Moteino uses INT2 as the RFM69W interrupt pin and I have added a entry into RF69_avr.h

#elif defined(__AVR_ATmega1284P__) // Moteino MEGA
// http://lowpowerlab.com/moteino/#whatisitMEGA

#define RFM_IRQ     2 
#define IRQ_NUMBER  2
#define SS_DDR      DDRB
#define SS_PORT     PORTB
#define SS_BIT      4

#define SPI_SS      4
#define SPI_MOSI    5
#define SPI_MISO    6
#define SPI_SCK     7

Similarly I have updated RF69_compat.cpp around the attachinterrupt:

#if defined(__AVR_ATmega1284P__) // Moteino MEGA
#define irq_number 2
#else
#define irq_number 0
#endif
.
.
        attachInterrupt(irq_number, RF69::interrupt_compat, RISING);
.

Receiving appears to work but there is a problem with transmit.
The first packet offered to the RFM69W causes the interrupt to fire indicating the transmission is complete but nothing is transmitted. The second packet offered does not cause an interrupt and the third cannot be offered because rf69_canSend returns false.

I have gone through the code a number of times and one area that I do not understand is:

uint8_t RF69::control(uint8_t cmd, uint8_t val) {
    PreventInterrupt irq2; //irq0;
    return spiTransfer(cmd, val);
}

This is used by writeReg presumably to prevent interrupts at critical times. I am concerned that “PreventInterrupt” appears to accept anything at all where I currently have irq2. Since it will accept anything including xxx and the IDE doesn’t throw up any errors I am unsure if the correct value is being accepted. PreventInterrupt is a structure with IRQ_NUMBER = 2 in my case:

struct PreventInterrupt {
    PreventInterrupt () { EIMSK &= ~ _BV(IRQ_NUMBER); }
    ~PreventInterrupt () { EIMSK |= _BV(IRQ_NUMBER); }
};

Can anyone shed any light of how to improve on my situation?


Replies (13)

RE: RF12Demo with Moteino Mega1284P - Added by cadwal over 4 years ago

I don’t think you need to worry about the name of the PreventInterrupt variable, it is just a name.

As you noted, in the implementation it uses the definition of the correct IRQ.

A neat but perhaps somewhat opaque use of variable scoping and destructors given the name confusion, possibly feeding it the IRQ number via templates or something would have been more obvious.

I am also interested in the Moteino Mega (or something similar), I had aquired all needed components to start designing/breadboarding a 1284p based node and now a ready made thing turned up. Now if we just had a bridge board to turn it into the JeeNode format without messy wiring….

So, unfortunately no help with your actual problem.

RE: RF12Demo with Moteino Mega1284P - Added by JohnO over 4 years ago

Thanks for the response cadwal, I had just that minute decided that the string “irq0” is some type of a lock string that is keyed by PreventInterrupt. My attempts to use INT2 failed since that was already defined, presumably in pins somewhere. Am I right in saying:

            PreventInterrupt arbitrary_interlock_string;

Provided I don’t have “arbitrary_interlock_string” defined elsewhere?

RE: RF12Demo with Moteino Mega1284P - Added by cadwal over 4 years ago

Yes.

Actually you should only need to worry about names in the same scope, but preprocessor defines might have an effect if they turn the variable name into code that wont compile. Like INT2 apparently did.

(Using templates would waste code space, now that I think about it)

RE: RF12Demo with Moteino Mega1284P - Added by JohnO over 4 years ago

After the first transmit the RFM69W appears to be stuck in RegOpMode = 0xC0, Sequencer off + ListenOn whereas a working node idles with RegOpMode at 0x10 Receiver Mode.

RE: RF12Demo with Moteino Mega1284P - Added by JohnO over 4 years ago

Could access to the SPI be being blocked during the interrupt as the first transmission ends?

I ask because I have added some debugging:

      writeReg(REG_SYNCVALUE6, readReg(REG_OPMODE));      //DEBUG

With the above line at the end of the sendStart_compat procedure I can recover the expected value 0x0C but if I add the line in the interrupt routine I only see 0xFF. I was expecting to see 0xC0 - the problem idle position. Perhaps it is just blocking any changes to the REG_OPMODE.

RE: RF12Demo with Moteino Mega1284P - Added by JohnO over 4 years ago

The same test on a 328 recovered the value 0x04 rather than 0xFF corresponding with Standby mode which is fine since the debug command followed:

            setMode(MODE_STANDBY);

RE: RF12Demo with Moteino Mega1284P - Added by JohnO over 4 years ago

Felix suggested dropping the SPI speed as he has seen issues with full speed SPI. Have tried it all the way down to 1M and seeing exactly the same issue.

RE: RF12Demo with Moteino Mega1284P - Added by JohnO over 4 years ago

Worth noting that I am using Arduino IDE 1.0.5 Release 2 since that is the version recommended for Moteino. My parallel testing with 328P has used the same version as Moteino.

RE: RF12Demo with Moteino Mega1284P - Added by JohnO over 4 years ago

cadwal wrote:
> I am also interested in the Moteino Mega (or something similar), I had acquired all needed components to start designing/breadboarding a 1284p based node and now a ready made thing turned up. Now if we just had a bridge board to turn it into the JeeNode format without messy wiring….

I don’t think my MEGA will ever fly, if you every get to the PCB stage with a 1284P design I will happily share at some PCB costs.

RE: RF12Demo with Moteino Mega1284P - Added by cadwal over 4 years ago

Now, that is probably were the problems will turn up. Design, breadboarding and software I feel fairly comfortable with, but turning it into a PCB ….

Regarding your Moteino problem, have you tried with with Felix’s libraries to see if you can get through multiple transmissions with those? If that is the case, then it really is a software problem.

RE: RF12Demo with Moteino Mega1284P - Added by plutonomore over 4 years ago

Hi John,

Have been reading your recent 1284P posts here and on LowPowerLabs site. Can appreciate that you have several JeeNodes that you want to still use, hence the desire to
hang on to the RFM12B library. Could I possibly suggest moving onto the RFM69 library. I was in a similar predicament a while back but decided that the short-term pain of
the upgrade was warranted, when looking forward. Also, I have had no problems with my 1284P design and RFM69HW hardware and Felix Rusu’s library. So, if you want
your MEGA to fly, maybe this is the easiest way to go.

cheers,

RE: RF12Demo with Moteino Mega1284P - Added by JohnO over 4 years ago

Good to hear from you again plutonomore I have now found my problem and it was my soldering after all my fussing. I had a high resistance on the GND to the radio. I blame the odd silver coating on the Moteino solder pads, I know you are a very good with solder and the pads probably don’t irritate you like they do me.

I did try the RFM69 library in order to get some support from Felix with the MEGA hardware and it still didn’t work - why would it without a good ground.

To be honest I think the support from the Jee folks, Martyn & jcw has spoiled me for anything less. I feel the commercial versus support tension when working with my MEGA problem confirmed my position to stick with the Jeelabs library and hardware as available. I have also spent a lot of time in the Jeelabs RF library code and now feel very comfortable with jcw’s style even though he can be a challenge for a novice like me.

I’m glad you are getting on well with RFM69 and I think the Hope Radio community should share expertise. I note that Felix has recommended others to test their hardware with the Jeelabs library as part of fault finding and I think I know why.

Anyhow, take care and visit us again soon.

RE: RF12Demo with Moteino Mega1284P - Added by JohnO over 4 years ago

Its working now, a high resistance GND connection to the radio.

cadwal wrote:
> Now, that is probably were the problems will turn up. Design, breadboarding and software I feel fairly comfortable with, but turning it into a PCB .

Eagle is quite scary, I had some made once from a design on the net, they worked fine - I felt as I had achieved something when it was all the work of someone else.

> Regarding your Moteino problem, have you tried with with Felix’s libraries to see if you can get through multiple transmissions with those? If that is the case, then it really is a software problem.

I did try with Felix’s library and still had similar symptoms.

    (1-13/13)