Revised MRF24J40 driver code for STM32 and AVR

I meant to post this a while ago, but oh well :) A long time ago I made a basic driver for AVR, then I hacked it up a bit to make it run on the STM32L discovery board. None of the code was common, and the STM32 code was some of my earliest steps in that world. Last summer I started trying to put this all together, but I got busy with other things, and more particularly, I ditched the ST Standard Peripheral Lib and started actively working on libopencm3. Anyway, I eventually got back into project mode, and decided it was time to tidy this all up.

So, here it is. The 3rd edition of my MRF24J40 code. This one should be somewhat more portable to other platforms, as it uses function pointers to set up all the spi and interrupts. (As if anyone else is using this stuff anyway!)

There’s still plenty of tidying up that could be done, there always is, but it’s more going to be a base for further work on Contiki, so it’s probably about as good as it’s getting for now.

  1. Hi,
    First of all thanks for sharing all these resources and finding of yours.
    I am trying to use your MRF24J4 lib on an STM32L152. It seems that all initialisation goes OK, but if I write anything on the module’s registers and try to read it back, I alway get a zero value. This is been troubling me for over a week now and I just can’t find what am I doing wrong.
    If you have any idea or hint, the help would be much appreciated.

  2. If you’re not getting a reply at all, then you probably don’t actually have your spi config working.

  3. Hi KarlP,
    Thanks for your reply.
    I have double checked my spi config and all looks OK. Plus the Status register bits (SR_RXNE and SR_TNE) are being set by hardware correctly, which I guess means that connection with the MRF is established (?).

    Now the problem is that if I write something (for example if I use the mrf_pan_write funtion), and try to read the it back, it always returns 0 (whereas the the SPI transmit and receive statuses are being set correctly).

    I much appreciate the help.

  4. Hello KarlP,
    I have an Arduino Leonardo board and I want to connect it with MRF24J40MA, I ‘ve seen the pin out diagram of this board. one of the differences between Uno and Leonardo is the SS pin of LEO board are not shown directly (RXLED) and it is called Digital pin 17. I’ ve declared D17 as CS pin for MRF24J40 but it doesnt work. May you give me a pin mapping diagram between MRF24J40 and Arduino Leonardo please??? Thanks…

  5. I’m afraid I’ve never looked at the pinouts for this on arduino boards, and I won’t be. Further, I kinda believe 802.15.4 for personal projects is a dead end, wifi and btle are eating it for dinner for most practical concerns.

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>