NMEA2000
NMEA2000 copied to clipboard
NMEA2000 stm32 mcp2515
Hi. I’m trying to use this great NMEA2000 library on a STM32. How do I specify which SPI port to use? I also have a TFT connected, which needs max SPI-speed, but the CAN controller has a max of 10MHz, so I want to use two SPI-ports on my STM32.
Im using a Bluepill, but changed the STM to a STM32F103CBT6 (more memory). I’m using Visual Studio Code with PlatformIO - a ST-LINK for upload/debug, a MCP2515 as controller and MCP2542 for transceiver.
Libraries (Timo’s): N2kMsg.h NMEA2000.h mcp_can.h NMEA2000_mcp.h N2kMessages.h
The micro should have 2xSPI, but I can’t find info how to use SPI2 Just tell me if you need more information…
You can have tNMEA2000_mcp NMEA2000(CS_Pin);
and then on setup NMEA2000.SetSPI(&SPI2); ... NMEA2000.Open();
Damn.....can't make it work :-(
Could(would) you maybe help me a little - i'm just trying to make the "TemperatureMonitor" work on a STM32F411RE Nucleo board.
Apparently Im to stupid.... I have the MCP2515 connected to SPI2 as this: CS PC0 MISO PC2 MOSI PC3 SCLK PC7
Please - where do I select the pins to use as alternate functions - and define the CS - and select SPI2? I'd realy appreciate your help ;-)
Sorry for the late reply! I couldn't reach NMEA2000.SetSPI(&SPI2), but this did the trick:
tNMEA2000_mcp* pNMEA = (tNMEA2000_mcp*) &NMEA2000; pNMEA->SetSPI(&SPI_2);