This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

MCP2515 Library for NRF52

Hi everyone,

Im working and learning for private project CAN bus sniffer which when receive some data trigger some relay...

I have mcp2515_can hw-184 board on which Im replace TJA1050 chip for SN65HVD230. Im add J1 jumper to connect 120ohm resistor. Then Im connect on other side Lawicel CANUSB device together with CANHack software and open 500k CAN connection and periodicly send some data...

Im try few MCP2515 library written in C but looks like none of them do not work or maybe Im do something wrong... I don't have any special tool to analyze frequency on SPI interface...

I use in software:

SPI_SCK_PIN = P0.26

SPI_MISO_PIN  = P0.30

SPI_MOSI_PIN = P0.29

SPI_SS_PIN = P0.31

Connections:

MCP2515 <-> NRF52840 PDK

INT - No connection

SCK <-> P0.26

SI <-> P0.29

SO <-> P0.30

CS <-> P0.31

GND <-> GND

VCC <-> VDD

MCP2515:

NRF52840:

Any hint what to check that I will be sure that SPI interface and connections are ok and I have only software problems? Or is here some working MCP2515 library compatible with NRF5 SDK 17.0.2 ? Or maybe can I somehow change SPI example to test that MCP2515 realy work? I will and I use Softdevice S140(BLE peripheral) if this is important...

Thanks for any help.

Parents
  • Im check mcp2515_write_canMsg function and see that in function is used:

    uint8_t* m_tx_buf = malloc(6+len * sizeof(uint8_t));

    Im new in C and microcontroller developing and after search found that maybe there is memory problem and Im add at end of function free function:

    free(m_tx_buf);

    Im also replace all __WFE with:

    if (nrf_sdh_is_enabled())
    {
         sd_app_evt_wait();
    }
    else
    {
            __WFE();
    }

    This is solve crash after 512 messages. Now I must analyze and check why data field is empty in CAN message... But this is all for today because Im spend to much time learning CAN bus and developing in C ...

Reply
  • Im check mcp2515_write_canMsg function and see that in function is used:

    uint8_t* m_tx_buf = malloc(6+len * sizeof(uint8_t));

    Im new in C and microcontroller developing and after search found that maybe there is memory problem and Im add at end of function free function:

    free(m_tx_buf);

    Im also replace all __WFE with:

    if (nrf_sdh_is_enabled())
    {
         sd_app_evt_wait();
    }
    else
    {
            __WFE();
    }

    This is solve crash after 512 messages. Now I must analyze and check why data field is empty in CAN message... But this is all for today because Im spend to much time learning CAN bus and developing in C ...

Children
No Data
Related