NUCLEO-F767ZI CAN Bus Pin Mapping Error: 'pinmap not found for peripheral'

Hello,

I am working on establishing CAN Bus communication on my NUCLEO-F767ZI board but keep encountering the error “pinmap not found for peripheral”. I am using PB_9 (CAN_TX) and PB_8 (CAN_RX) as the CAN pins. Below is the code I am using. I have ensured that I am using the latest version of Mbed OS.

#error [NOT_SUPPORTED] CAN not supported for this target
#endif

#include "mbed.h"

Ticker ticker;
DigitalOut led1(LED1);
DigitalOut led2(LED2);

/** The constructor takes in RX, and TX pin respectively.
  * These pins, for this example, are defined in mbed_app.json
  */
CAN can1(PB_9, PB_8);
char counter = 0;
volatile bool send_flag = false;

const int SDO_COB_ID = 0x601;

void ticker_callback() {
    send_flag = true;
}

void send()
{
    // Create SDO message
    char data[8] = {0x22, 0x01, 0x00, 0x00, counter, 0x00, 0x00, 0x00}; // SDO write command (0x22) to object 0x0001, sub-index 0x00
    CANMessage sdoMsg(SDO_COB_ID, data, 8);
    led1 = !led1;
}

int main()
{
    ticker.attach(&ticker_callback, 0.2); // 200 ms interval
    CANMessage msg;
    while (1) {
        if (send_flag) {
            send_flag = false; // Reset the flag
            send();
        }
        ThisThread::sleep_for(200ms);
    }
}


Hello,

CAN API constructor sais - CAN (PinName rd, PinName td)

Nucleo-F767ZI CAN pins
image

RD = PB_8
TD = PB_9

You have

This means you have twisted pins in the constructor. It should look like

CAN can1(PB_8, PB_9);

BR, Jan