NMEA2000 icon indicating copy to clipboard operation
NMEA2000 copied to clipboard

NMEA2000 stm32 mcp2515

Open JensJespersen opened this issue 2 years ago • 3 comments

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…

JensJespersen avatar Jun 09 '22 15:06 JensJespersen

You can have tNMEA2000_mcp NMEA2000(CS_Pin);

and then on setup NMEA2000.SetSPI(&SPI2); ... NMEA2000.Open();

ttlappalainen avatar Jun 09 '22 17:06 ttlappalainen

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 ;-)

JensJespersen avatar Jun 13 '22 17:06 JensJespersen

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);

JensJespersen avatar Jun 23 '22 15:06 JensJespersen