Hi everyone,
I am trying to connect an MCP2515 module to the arduino Nicla Vision. The SPI is wired with CS = GPIO2 (PA10). I tested only with that module connected.
I use the pyb library I would like to use only the command
SPI(4, SPI.MASTER)
But I have to use a prescaler to avoid crashing the card.
This is a very simplified extract of the code but it still crash :
from pyb import Pin, SPI
_DEBUG = True
def print_debug(message):
if _DEBUG : print(message)
class CAN:
def __init__(self) -> None:
self._SPICS = Pin('PA10', Pin.OUT)
self._SPI = SPI(4, SPI.MASTER)#, polarity=0, phase=0)#, prescaler = 10, , , firstbit = SPI.MSB) #baudrate = 1000000,
print_debug("End SPI build")
if self.reset() != ERROR_OK: print("Can not reset for MCP2515")
print_debug("End Initialisation")
def SPI_start(self) -> None:
self._SPICS.low()
def SPI_end(self) -> None:
self._SPICS.high()
def reset(self) -> int:
self.SPI_start()
value=0xC0
#value=value.to_bytes(1, sys.byteorder)
self._SPI.send(value)
self.SPI_end()
print_debug("Reset OK")
return 0
can = CAN()
Moreover, it seems that it crash so rapidly that the IDE can’t receive Serials because I can’t print anything. (it work with the “prescaler version”).
Then the IDE popup a message “busy… try later” ???
Does anyone have an idea for my problem ?
Thank you very much for helping me.