Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPI connection with Arduino Nano 33 BLE #23

Open
Marittia opened this issue Jul 15, 2021 · 5 comments
Open

SPI connection with Arduino Nano 33 BLE #23

Marittia opened this issue Jul 15, 2021 · 5 comments

Comments

@Marittia
Copy link

Hello!
First of all, thanks a lot for the library.

I currently have a MCP2518FD-Click and i wanted to use it along with my Arduino 33 nano BLE.

I already tried the example LoopBackDemoArduinoUno with an Arduino Uno and everything works fine.

But when i switch to the Arduino Nano the code seems to stuck (Arduino IDE stops working as long as i don't disconnect the Arduino from the USB) when calling the function "writeRegister8" inside ACAN2517FD::begin.
Could it be something wrong with the SPI communication? I double checked the wiring and it seems to be correct (it's equal to the one on my Arduino Uno).

Also, i'm using the MCP2518 with jumper on VIO=3.3 (used a shifter with arduino UNO) and i'm connecting both 3.3V and 5V.

Thanks for your time!

@pierremolinaro
Copy link
Owner

pierremolinaro commented Jul 17, 2021 via email

@Marittia
Copy link
Author

Marittia commented Jul 19, 2021

I'm using the same wiring you're describing.
For CS i'm using pin D6 and for INT pin D7 (i saw that every pin on the Nano is interruptable). I also tried with some other different CS and INT pins, but none of the tries worked out.

Tomorrow i will be able to test it a bit further and see what can cause the problem.

For now, thank you very much!

@Marittia
Copy link
Author

Marittia commented Jul 21, 2021

Hello!
Thanks for the help. So far i recognized the "IDE stuck while Arduino is connected" was due to the code blocking (maybe an infinite loop?) after a noInterrupts() call. So what i did was basically commenting all the "noInterrupts()" i found in the library code. The result is that now the Begin function seems to succeed (errorCode = 0).

Still the InternalLoop mode doesn't work, and i saw that in NormalFD mode my can sniffer is able to read only the first packet, all the other ones cannot be sent. Do you happen to have any idea about what could be the problem?

Also, i noted that with noInterrupts enabled it seems to stuck inside this portion of code here, right after writing and the reading back MCP2517FD RAM at address 0x400:

//----------------------------------- Check SPI connection is on (with a 1 MHz clock)
// We write and the read back MCP2517FD RAM at address 0x400
Serial.println("This will be printed");
  for (uint32_t i=1 ; (i != 0) && (errorCode == 0) ; i <<= 1) {
    const uint16_t RAM_WORD_ADDRESS = 0x400 ;
    writeRegister32 (RAM_WORD_ADDRESS, i) ;
    const uint32_t readBackValue = readRegister32 (RAM_WORD_ADDRESS) ;
    if (readBackValue != i) {
      errorCode = kReadBackErrorWith1MHzSPIClock ;
    }
  }
Serial.println("This won't!");

Thank you very much once again,
Mariano

@pierremolinaro
Copy link
Owner

pierremolinaro commented Jul 24, 2021 via email

@jmFernandezMola
Copy link

jmFernandezMola commented Nov 1, 2022

Hi there,
I have the same problem of Marittia. After some investigations I found this:
"Note that disabling interrupts on the Arduino boards with native USB capabilities (e.g., Leonardo) will make the board not appear in the Port menu, since this disables its USB capability." In the nointerrupts() reference from arduino (here). Arduino Nano 33 BLE seems to be affected by this also. I hope this comment sheds some light.
Best regards,
JM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants