I am trying to connect a nrf5340dk to a Jetson. For now I am testing with an Arduino. I am trying to run the CanCounter example with a device tree overlay file. Also I would like to connect this to a Jetson Orin in the future. This is my current setup and below is my code.
I am using
2x I2C Logic Level Converter (because of the different voltage levels)
2x MCP2515 CAN Bus Shield AZDelivery
And I am powering the nrf5340dk using the J2 USB connector
Is there anything I am doing incorrectly?
I am able to build and flash to the nrf board but I get the following error message;
uart:~$ *** Booting nRF Connect SDK v3.5.99-ncs1-1 ***
Error starting CAN controller [-5]
nrf5340dk_nrf5340_cpuapp.overlay:
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
&spi4 {
status = "okay";
cs-gpios = <&gpio1 9 GPIO_ACTIVE_LOW>;
pinctrl-0 = <&spi4_default>;
//pinctrl-names = "default";
canbus:mcp2515@0 {
compatible = "microchip,mcp2515";
spi-max-frequency = <1000000>;
int-gpios = <&gpio1 10 (GPIO_ACTIVE_LOW)>;
status = "okay";
label = "CAN_1";
reg = <0x0>;
osc-freq = <16000000>;
bus-speed = <500000>;
sjw = <1>;
prop-seg = <2>;
phase-seg1 = <7>;
phase-seg2 = <6>;
#address-cells = <1>;
#size-cells = <0>;
proj.conf:
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
CONFIG_POLL=y
CONFIG_CAN=y
CONFIG_CAN_INIT_PRIORITY=80
#CONFIG_CAN_MAX_FILTER=5
CONFIG_SHELL=y
CONFIG_CAN_SHELL=y
CONFIG_DEVICE_SHELL=y
CONFIG_GPIO=y
CONFIG_STATS=y
CONFIG_STATS_NAMES=y
CONFIG_STATS_SHELL=y
CONFIG_CAN_STATS=y
main.cpp:
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
* Copyright (c) 2018 Alexander Wachter
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdio.h>
#include <zephyr/kernel.h>
#include <zephyr/sys/printk.h>
#include <zephyr/device.h>
#include <zephyr/drivers/can.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/sys/byteorder.h>
#define RX_THREAD_STACK_SIZE 512
#define RX_THREAD_PRIORITY 2
#define STATE_POLL_THREAD_STACK_SIZE 512
#define STATE_POLL_THREAD_PRIORITY 2
#define LED_MSG_ID 0x10
#define COUNTER_MSG_ID 0x12345
arduino_code.ino:
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <SPI.h>
#include <mcp2515_can.h>
const int spiCSPin = 10; // Set the CS pin for MCP2515 CAN shield
const int ledPin = 13; // Use the built-in LED on pin 13
mcp2515_can CAN(spiCSPin);
void setup() {
Serial.begin(115200);
pinMode(ledPin, OUTPUT);
// Initialize CAN bus at 500kbps
while (CAN_OK != CAN.begin(CAN_500KBPS)) {
Serial.println("CAN BUS init Failed");
delay(100);
}
Serial.println("CAN BUS Shield Init OK!");
}
void loop() {