Shop OBEX P1 Docs P2 Docs Learn Events
MCP2515 PASM based SPI-engine object, trouble sending messages — Parallax Forums

MCP2515 PASM based SPI-engine object, trouble sending messages

avionikerenavionikeren Posts: 64
edited 2014-07-24 12:09 in Propeller 1
Hi,

I have trouble sending CAN messages with this object.
The first transmitted message is almost correct except for the last byte, but the next ones are not even close to correct.
It looks like the pointer to DataBufferTx is only used the first time, then the adress to read from in ram is increased for each loop.

I have attached my code and a screenshot of what is received in the other end.

I guess the answer is simple, but I am totally stuck, does anyone else see what the problem is?

CAN screenshot.jpg

CAN test.spin
MCP2515-SPI Engine.spin

Comments

  • ChrisGaddChrisGadd Posts: 310
    edited 2014-07-24 09:53
    There seems to be two bugs in the OUT1OUT13_ routine; the first bug is caused by failing to reinitialize the source of :SNxtLongI, which causes it to read from incorrect addresses. The second bug is responsible for the final byte, and here I have no idea what the original intent was, but the solution seems to be to set msBitMask to #$80. Here's the corrected code:
                  movs    :SNxtLongI,      #nIntrnlBffr0
                  nop
    :SNxtLongI    mov     arg0,            nIntrnlBffr0     ' copy 1st word into location being sent
                  mov     nbrBits,        #32               ' Load/reload number of data bits
                  call    #SendLong                          ' go send 32 bits
                  add     :SNxtLongI,#1                     ' point to next COG long to be sent
                  djnz    bytXferCt,#:SNxtLongI             ' if more longs to be sent, go do next
                  and     arg0,           #1        wz,nr   ' LS-bit of command indicates what we are sending
            if_nz jmp     #:SendExit                        ' if short form (8vs13) then skip 13th byte
                  mov     arg0,            nIntrnlBffr3     ' MS-8bits is 13th byte to be sent
                  mov     nbrBits,        #8                '     Load number of data bits (send MS-8bits)
    '             mov     msBitMask,      #$08              '          Create MSB mask     ;     load with "1"
    '             rol     msBitMask,      #24               '          Shift "1" N number of bits to the left.
                  mov     msBitMask,      #$80
                  call    #WRnBITS
    
  • avionikerenavionikeren Posts: 64
    edited 2014-07-24 12:09
    Thanks a lot Chris! This fixed the problem.
Sign In or Register to comment.