11 years, 7 months ago.

Initialization.

Hi,

Thank you for the library.

I've imported it in a project for a KL25Z board. It did not worked from the beginning as the RF22 class constructor did not initialized correctly the SPI and CS lines. I added in RF22::RF22 the following lines: DigitalOut _slaveSelectPin(slaveSelectPin); DigitalOut led1(LED_RED); DigitalOut led2(LED_GREEN); DigitalOut led3(LED_BLUE); SPI _spi(mosi, miso, sclk); InterruptIn _interrupt(interrupt);

I cannot explain why is not working other that maybe the constructor is executed before the M0+ micro is ready.

Anyway since I have no background in RF communications, I have no idea how to configure everything to be able to read the wireless temperature sensor from my cheap weather station. I've understand that it's an OOK @ 433.92 MHz with 9ms sync bit and 4ms the "1" bit and 2ms the "0" bit.

Have you used it with anything other then another RF22 transceiver?

Thank you. Have a great weekend.

Question relating to:

3 Answers

11 years, 7 months ago.

The issue with the KL25Z is that the LED_BLUE pin and the SPI CLK are all connected to the same pin PTD1 (see KL25Z schematic). You can not use SPI CLK on pin PTD1 and LED_BLUE at the same time. The declaration order will decide which pin function gets disabled. In your case you redefined the orinal order of the constructor to make sure SPI is declared last and SCK is activated.

RF22::RF22(PinName slaveSelectPin, PinName mosi, PinName miso, PinName sclk, PinName interrupt)
    : _slaveSelectPin(slaveSelectPin), _spi(mosi, miso, sclk), _interrupt(interrupt), led1(LED_RED), led2(LED_GREEN), led3(LED_BLUE)
{
    DigitalOut _slaveSelectPin(slaveSelectPin);
    DigitalOut led1(LED_RED);
    DigitalOut led2(LED_GREEN);
    DigitalOut led3(LED_BLUE);
    SPI _spi(mosi, miso, sclk);
    InterruptIn _interrupt(interrupt);
...

Your options are: remove LED_BLUE or replace it by NC or remap the SPI port to other pins.

Accepted Answer
11 years, 7 months ago.

Hi Dan!

Sorry for the late answer, but I didn't see your question on my Libraray.

I'm not sure about the initialization-problem. I have a mbed LPC1768 and here it works. Where exactly did you add there statements? In the RF22.cpp - line 60? I can test if this works for the lpc1768 too and the add to the library.

No, till now I only tested this library for communication between two RFM22B's an this works out of the box. But I want to read a window-shutter contact with the RF22. Until now this only works with a RFM12B and a code, which does all the decoding. But if you don't know the protocol of your sensor, or don't find anything about it on the internet, it will be hard without much work! See here for the RFM12B: https://mbed.org/users/charly/notebook/connecting-a-radio-window-shutter-contact-to-knx/

Charly

11 years, 7 months ago.

Hello,

Yes, I added it somewhere around line 60 like this:

RF22::RF22(PinName slaveSelectPin, PinName mosi, PinName miso, PinName sclk, PinName interrupt)
    : _slaveSelectPin(slaveSelectPin), _spi(mosi, miso, sclk), _interrupt(interrupt), led1(LED_RED), led2(LED_GREEN), led3(LED_BLUE)
{
    DigitalOut _slaveSelectPin(slaveSelectPin);
    DigitalOut led1(LED_RED);
    DigitalOut led2(LED_GREEN);
    DigitalOut led3(LED_BLUE);
    SPI _spi(mosi, miso, sclk);
    InterruptIn _interrupt(interrupt);
...

Well it's hard to explain why is not working. What I did to have the SPI comunication working is not the right way to do it. I'm thinking that when the class constructor is executed the micro-controller on my KL25Z board is not ready or does not agree with the port mode change and if done again micros later it switches correctly.

I wanted to try with a new() constructor in the main function but unfortunately I did no managed to do any other test as I have to relocate in a month and there is no time for fun anymore :)

In a way I have some information on the protocol but did not received any frame. Maybe there it has to do with my RF22 connection and also, the temperature sensor transmits just every 1 minute a frame making testing a pain.

Thank you for the answer.