RF69 crashes on sending a message.

Added by rolfhand 12 days ago

Using the rf69.fs library on a blue pill wit RFM69HW i'm trying to send an 4 byte binary message. It works so far that when succesfull I do receive the expected data (byte, byte, 16 bit number) correctly. But after 1 or 2 sended messages the system crashes with an Unhandled Interrupt 00000003 ! and a stack with strange data .

Adding a rf-init to the sendmsg word did not help and stack handling seems to be OK. Strangely enough when using sendcmd from another command, see sendtst, it will take more iterations before crashing.

I have used the old (jwc)and the new (tve) rf69.fs versions with same result.
n.b. Latest rf69.fs expects a LED to be initiated which is not in the standard always, board, core libraries for the blue pill, so it does not compile before fixing this.

: sendcmd ( to opcode n -- )   \ rf-msg is a 4 byte buffer
    rot rf-msg c!                   \  to at byte 1
    swap rf-msg 1 + c!              \ opcode at byte 2
    rf-msg 2 + !                    \ n at byte 3 and 4
    rf-msg 4 0 rf-send ;

: sendtst 11 22 100 sendcmd
      33 44 300 sendcmd
      1 2 3 sendcmd ;

Replies (2)

RE: RF69 crashes on sending a message. - Added by jcw 8 days ago

I think this code has a word alignment issue: rf-msg 2 + ! should probably be rf-msg 2 + h! ?
The Cortex M0 does not support misaligned word writes (whereas the M3, i.e. F103, does).

RE: RF69 crashes on sending a message. - Added by rolfhand 7 days ago

I'am using a F103 Blue Pill but your suggestion did help indeed. Thanks. Additionally, when sending messages in a loop with low single byte numbers, i had to put a couple of ms delay between the messages. I'm courious about your suggestion for sending multiple values (blogpost tonight).