Currently, mbed_portenta core has some bug, making analogWrite crashing the Portenta_H7
Just try the simplest code and see
#define LEDB_PIN 25
void setup()
{
pinMode(LEDB_PIN, OUTPUT);
Serial.begin(115200);
while (!Serial);
delay(100);
Serial.print(F("\nStarting analogWrite_Crash on ")); Serial.println(BOARD_NAME);
analogWrite(LEDB_PIN, 150);
}
void loop()
{
}
If possible, you can open an issue on ArduinoCore-mbed issues