nrf9160dk_nrf9160 v0.9.0 mcp2515 canbus decoding problems (SPI is working)

This is the next step of the process getting the canbus working with nrf9160 and the aditional MKR CAN shield from arduino


previus part can be read here 

https://devzone.nordicsemi.com/f/nordic-q-a/81754/nrf9160dk_nrf9160-v0-9-0-v1-7-1-mcp2515-canbus-build-problems


As requested from the previus ticket i have checked the SPI bus and it seems to work.


This is the text on the terminal:

[00:00:00.201,599] <dbg> mcp2515_can.socket_can_init: Init socket CAN device 0x2a698 (SOCKET_CAN_1) for dev 0x2a6c8 (CAN_1)
[00:00:00.217,041] <dbg> net_core.net_init: (main): Priority 90
[00:00:00.225,646] <dbg> net_core.l3_init: (main): Network L3 init done
[00:00:00.234,954] <dbg> mcp2515_can.socket_can_iface_init: Init CAN interface 0x20014a08 dev 0x2a698
uart:~$ *** Booting Zephyr OS build v2.7.0-ncs1  ***
[00:00:00.251,403] <inf> net_socket_can_sample: sleeping for 5 seconds
[00:00:05.260,772] <dbg> net_ctx.net_context_bind: (main): Context 0x200154d8 binding to 1 iface[2] 0x20014a08
[00:00:05.273,559] <dbg> net_conn.conn_register_debug: (main): [0x20015974/1/4/0x05] remote -/0
[00:00:05.285,064] <dbg> net_conn.conn_register_debug: (main):   local ?/0 cb 0x17931 ud (nil)
[00:00:05.296,417] <dbg> net_sock_can.can_register_filters: (main): Registering 1 filters
[00:00:05.307,281] <dbg> net_sock_can.can_register_receiver: (main): Max 1 receivers
[00:00:05.317,840] <dbg> net_socket_can_sample.setup_socket: Started socket CAN TX thread
[00:00:05.328,704] <inf> net_socket_can_sample: 1st RX fd 0
[00:00:05.336,975] <inf> net_socket_can_sample: caaling rx command
[00:00:05.345,855] <dbg> net_socket_can_sample.rx: [0] Waiting CAN data...
[00:00:06.317,871] <dbg> net_socket_can_sample.tx: Sending CAN data...



  • I see that i marked the signals MISO twice.
    From bottom should be marked: MOSI MISO SCLK SS

  • Hello Tomas,

    I read through the previous ticket and saw that you initially had some issues building the Socket CAN sample combined with the Arduino MKR CAN Shield.

    As requested from the previus ticket i have checked the SPI bus and it seems to work.

    Looking at this case, I can see that you have been able to solve them and it seems like the application is running and communicating via SPI.

    This is the next step of the process getting the canbus working with nrf9160 and the aditional MKR CAN shield from arduino

    But I’m honestly not quite sure what kind of issue it is you are facing in what you refer to as “the next step”. Can you elaborate?

    Thanks & regards,

    Markus

  • Hi Markus.

    Maybee i have missunderstand the functionallity of this example.
    I belived that the code sould print the recived canbus data, but after a closer look maybee thats not the case.

    If this is not the case ,what aditional code do i have to add.
    The goal is to read data from the canbus and then send it to AWS. 

    nb. i hawe been able to send information to AWS by using this example: 
    developer.nordicsemi.com/.../README.html

    Regards Tomas

  • Hello Tomas,

    T.B-D said:
    Maybee i have missunderstand the functionallity of this example.
    I belived that the code sould print the recived canbus data, but after a closer look maybee thats not the case.

    Thanks a lot for your feedback!

    T.B-D said:
    If this is not the case ,what aditional code do i have to add.

    Well, the Socket CAN sample should a least transmit something, namely a CAN frame with ID 0x1 and 8 bytes of data with content 0xF0.

    But it should also receive data and output it to the terminal. Is there any on-going traffic on the CAN bus your Arduino MKR CAN Shield is connected to? I assume that the shield itself has filters that needs to be configured to pass data in both directions.

    Regards,

    Markus

  • Hi Marcus.

    You are right that in CanBus you can apply filters. This filter prevent the MCU reciving messages that is primarly not of interst for your applications.
    This filters are normally set during the botup of the system. 

    How to setup the filres are expained here
    www.youtube.com/watch
    If no filter is set the MCU recive all data.

    I connected my MKR CAN shield  to my MRK1500 and i reciving this data fom my machine.
    (So i expect the same in the Socket CAN sample.)

    Regarding having the 

    CAN Receiver
    Received packet with id 0x714 and length 1
    0
    
    Received packet with id 0x720 and length 1
    0
    
    Received packet with id 0x620 and length 8
    40E72300000
    
    Received packet with id 0x622 and length 8
    40E72300000
    
    Received packet with id 0x624 and length 8
    40E72300000
    
    Received packet with id 0x5A0 and length 8
    4BE723089500
    
    Received packet with id 0x620 and length 8
    2B05102000
    
    Received packet with id 0x5A0 and length 8
    6005100000
    
    Received packet with id 0x620 and length 8
    2320592609620
    
    Received packet with id 0x5A0 and length 8
    60205920000
    
    Received packet with id 0x3F0 and length 3
    000
    
    Received packet with id 0x0 and length 2
    120
    
    Received packet with id 0x470 and length 5
    C01C2A814
    
    Received packet with id 0x1A0 and length 8
    0B000000

    Well, the Socket CAN sample should a least transmit something, namely a CAN frame with ID 0x1 and 8 bytes of data with content 0xF0.

    I don´t get any CAN data  from the nrf9160DK .

    Is the overlay correct ?

    /*
     * Copyright (c) 2020, Nordic Semiconductor ASA
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    /* Example configuration of a MCP2515 cancontrol device */
    
    
    &spi3 {
        status = "okay";
        sck-pin = <10>;
        mosi-pin = <11>;
        miso-pin = <12>;
        cs-gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
      
        can1: mcp2515@0 {
          compatible = "microchip,mcp2515";
    		spi-max-frequency = <500000>;
    		/*int-gpios = <31>; /* D2 */
            int-gpios = <&gpio0 31 GPIO_ACTIVE_LOW>; /* D2 */
    		status = "okay";
    		label = "CAN_1";
    		reg = <0x0>;
    		osc-freq = <16000000>;
    		bus-speed = <250000>;
    		sjw = <1>;
    		prop-seg = <2>;
    		phase-seg1 = <7>;
    		phase-seg2 = <6>;
    		#address-cells = <1>;
    		#size-cells = <0>;
        };
      };
     
    
    / {
    	aliases {
    		can-primary = &can1;
    	};
    };
    


Related