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...



Parents
  • Hello Tomas,

    Thanks a lot for the detailed feedback!

    T.B-D said:
    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 

    Please note that the Socket CAN sample filters all incoming messages by default, except standard frame with ID 0x1. I can see that the filter is present in the application you shared in the previous case as well. From the log you provided I’m not able to see any frame with this ID.

    T.B-D said:
    Is the overlay correct ?

    Yes, it looks correct to me. But I’m not able to say anything about the external oscillator frequency, neither the bit segments. They should be aligned to the CAN shield & bus configuration.

    How is your CAN bus generally designed and set up?

    Regards,

    Markus

  • This is the code for the arduino example im running,
    github.com/.../MCP2515.h

    Yes, it looks correct to me. But I’m not able to say anything about the external oscillator frequency, neither the bit segments. They should be aligned to the CAN shield & bus configuration.

    How is your CAN bus generally designed and set up?

    oscillator frequency: #define MCP2515_DEFAULT_CLOCK_FREQUENCY 16e6

    My overlay is a copy i found in DevZone.
    Where do i find the information for the values marked with ? bellow.

    reg = <0x0>; --?
    osc-freq = <16000000>;  --OK
    bus-speed = <250000>;  --OK 
    sjw = <1>;  --?
    prop-seg = <2>;  --?
    phase-seg1 = <7>;  --?
    phase-seg2 = <6>;  --?
    #address-cells = <1>;  --?
    #size-cells = <0>;  --?

    If above values is wrong , will i still be abel to inizialse as bellow ? 

    [00:00:00.201,599] <dbg> mcp2515_can.socket_can_init: Init socket CAN device 0x2                                                                                                                                                             a698 (SOCKET_CAN_1) for dev 0x2a6c8 (CAN_1)
    [00:00:00.217,254] <dbg> net_core.net_init: (main): Priority 90
    [00:00:00.225,860] <dbg> net_core.l3_init: (main): Network L3 init done
    [00:00:00.235,168] <dbg> mcp2515_can.socket_can_iface_init: Init CAN interface 0                                                                                                                                                             x20014a08 dev 0x2a698
    uart:~$ *** Booting Zephyr OS build v2.7.0-ncs1  ***
    [00:00:00.251,617] <inf> net_socket_can_sample: sleeping for 5 seconds
    [00:00:05.260,986] <dbg> net_ctx.net_context_bind: (main): Context 0x200154d8 binding to 1 iface[2] 0x20014a08
    [00:00:05.273,742] <dbg> net_conn.conn_register_debug: (main): [0x20015974/1/4/0x05] remote -/0
    [00:00:05.285,217] <dbg> net_conn.conn_register_debug: (main):   local ?/0 cb 0x17931 ud (nil)
    [00:00:05.296,569] <dbg> net_sock_can.can_register_filters: (main): Registering 1 filters
    [00:00:05.307,434] <dbg> net_sock_can.can_register_receiver: (main): Max 1 receivers
    [00:00:05.317,993] <dbg> net_socket_can_sample.setup_socket: Started socket CAN TX thread
    [00:00:05.328,857] <inf> net_socket_can_sample: 1st RX fd 0
    [00:00:05.337,127] <inf> net_socket_can_sample: caaling rx command
    [00:00:05.345,977] <dbg> net_socket_can_sample.rx: [0] Waiting CAN data...
    [00:00:06.318,023] <dbg> net_socket_can_sample.tx: Sending CAN data...
    uart:~$
    


    I reprogrammed my arduino to sending this information. But it did not come threw.

      if (!CAN.begin(250E3)) {
        Serial.println("Starting CAN failed!");
        while (1);
      }
    }
    
    void loop() {
    
      Serial.print("Sending standard packet ...");
    
      CAN.beginPacket(0x1F4);
      CAN.write(0xA1);
      CAN.write(0xA2);
      CAN.write(0xA1);
      CAN.write(0x4B);
      CAN.write(0x45);
      CAN.write(0x6B);
      CAN.write(0x85);
      CAN.write(0xC3);
      CAN.endPacket();
    
      Serial.println("done sending package with id 0x1F4");
    
      delay(500);
      
        Serial.print("Sending extended packet ...");
    
      CAN.beginPacket(0x1BCDEF);
      CAN.write(0xA1);
      CAN.write(0xA2);
      CAN.write(0xA1);
      CAN.write(0x4B);
      CAN.write(0x45);
      CAN.write(0x6B);
      CAN.write(0x85);
      CAN.write(0xC3);
      CAN.endPacket();
    
      Serial.println("done sending package with id 0x1BCDEF");
    
      delay(500);


Reply
  • This is the code for the arduino example im running,
    github.com/.../MCP2515.h

    Yes, it looks correct to me. But I’m not able to say anything about the external oscillator frequency, neither the bit segments. They should be aligned to the CAN shield & bus configuration.

    How is your CAN bus generally designed and set up?

    oscillator frequency: #define MCP2515_DEFAULT_CLOCK_FREQUENCY 16e6

    My overlay is a copy i found in DevZone.
    Where do i find the information for the values marked with ? bellow.

    reg = <0x0>; --?
    osc-freq = <16000000>;  --OK
    bus-speed = <250000>;  --OK 
    sjw = <1>;  --?
    prop-seg = <2>;  --?
    phase-seg1 = <7>;  --?
    phase-seg2 = <6>;  --?
    #address-cells = <1>;  --?
    #size-cells = <0>;  --?

    If above values is wrong , will i still be abel to inizialse as bellow ? 

    [00:00:00.201,599] <dbg> mcp2515_can.socket_can_init: Init socket CAN device 0x2                                                                                                                                                             a698 (SOCKET_CAN_1) for dev 0x2a6c8 (CAN_1)
    [00:00:00.217,254] <dbg> net_core.net_init: (main): Priority 90
    [00:00:00.225,860] <dbg> net_core.l3_init: (main): Network L3 init done
    [00:00:00.235,168] <dbg> mcp2515_can.socket_can_iface_init: Init CAN interface 0                                                                                                                                                             x20014a08 dev 0x2a698
    uart:~$ *** Booting Zephyr OS build v2.7.0-ncs1  ***
    [00:00:00.251,617] <inf> net_socket_can_sample: sleeping for 5 seconds
    [00:00:05.260,986] <dbg> net_ctx.net_context_bind: (main): Context 0x200154d8 binding to 1 iface[2] 0x20014a08
    [00:00:05.273,742] <dbg> net_conn.conn_register_debug: (main): [0x20015974/1/4/0x05] remote -/0
    [00:00:05.285,217] <dbg> net_conn.conn_register_debug: (main):   local ?/0 cb 0x17931 ud (nil)
    [00:00:05.296,569] <dbg> net_sock_can.can_register_filters: (main): Registering 1 filters
    [00:00:05.307,434] <dbg> net_sock_can.can_register_receiver: (main): Max 1 receivers
    [00:00:05.317,993] <dbg> net_socket_can_sample.setup_socket: Started socket CAN TX thread
    [00:00:05.328,857] <inf> net_socket_can_sample: 1st RX fd 0
    [00:00:05.337,127] <inf> net_socket_can_sample: caaling rx command
    [00:00:05.345,977] <dbg> net_socket_can_sample.rx: [0] Waiting CAN data...
    [00:00:06.318,023] <dbg> net_socket_can_sample.tx: Sending CAN data...
    uart:~$
    


    I reprogrammed my arduino to sending this information. But it did not come threw.

      if (!CAN.begin(250E3)) {
        Serial.println("Starting CAN failed!");
        while (1);
      }
    }
    
    void loop() {
    
      Serial.print("Sending standard packet ...");
    
      CAN.beginPacket(0x1F4);
      CAN.write(0xA1);
      CAN.write(0xA2);
      CAN.write(0xA1);
      CAN.write(0x4B);
      CAN.write(0x45);
      CAN.write(0x6B);
      CAN.write(0x85);
      CAN.write(0xC3);
      CAN.endPacket();
    
      Serial.println("done sending package with id 0x1F4");
    
      delay(500);
      
        Serial.print("Sending extended packet ...");
    
      CAN.beginPacket(0x1BCDEF);
      CAN.write(0xA1);
      CAN.write(0xA2);
      CAN.write(0xA1);
      CAN.write(0x4B);
      CAN.write(0x45);
      CAN.write(0x6B);
      CAN.write(0x85);
      CAN.write(0xC3);
      CAN.endPacket();
    
      Serial.println("done sending package with id 0x1BCDEF");
    
      delay(500);


Children
No Data
Related