This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

MCP2515 with NRF51-DK

Hi,
I am trying to interface MCP2515 with nrf51-dk. MCP2515 talks over SPI, so I have taken SPI_master as my base code. I have used MCP with arduino, so I thought it would be best to modify that library which can be found here.
But when I'm trying to configure it, it is not giving correct data. So, I have following questions:

  1. Are the pins on the DK 5V tolerant? I haven't tried to give 5V signal, thinking it might get damaged.
  2. I'm supplying power to MCP using VDD of the board which provides around 2.9V when connected via USB. Will it damage the DK as I don't know how much current MCP will draw, although it works fine with arduino 5V.
  3. I've also changed the default SPI pins to my own as the Product Sheet states that the SPI pins are not fixed. I hope its alright. I'm using the following configuration:

SCK->4, MISO->2, MOSI->3, SS->1

  1. When I do spi_send_rcv, the received data is the previously buffered data or data according to the current command?
  2. Finally the last question, can someone help me debug the code or give me hints on how to?
    I've used RTT to debug the code, and I am now stuck at a point, I know where the issue is but I'm unable to figure out what to do with that? If someone needs more details, I can provide that too. Till then I'll refrain from making this post messy. I'm attaching the code if it can help.
    I apologize if the question is too much specific. I've been at the same position for over a week. Thanks in advance for the help :)
    spi_master.zip

Edit: When I don't write the rx_buf from spi_send_rcv to RTT terminal, application doesn't get into the function spi_send_rcv after 3 times. I think this is related to some memory issue, what can I do regarding this, as most of the times rx_buf is of no use to me. I tried replacing it with NULL but no success.

Parents
  • Hi

    1. No they are not. Maximum voltage is specified in the Product Specification as Vdd.

    2. This should not be a problem.

    3. This is no problem either.

    4. I'm not sure if I understand what you mean by this, but you decide what address in the MCP2515 you want to read from by sending a read instruction followed by a byte containing the address in the MCP2515 that you want to read from. From the MCP2515 datasheet 12.3. From the data sheet: Next, the data stored in the register at the selected address will be shifted out on the SO pin.

    5. My bet is that you are trying to transfer data too rapidly. I.e. the SPI is busy transferring data when you tell it transfer more data. The SPI transfer function spi_master_send_recv() will return the error code NRF_ERROR_BUSY if this is the case.

  • Hi, your 5th point was the answer. Figured it out the hard way by putting delays. Learned that error check is important. Thanks for the reply.

Reply Children
Related