I’ve used this board in the past without any problems, but it’s been a while so I just wanted to write a simple test program to test the Serial, HardwareTimer and SPI libraries.
#include <Arduino.h>
#include <HardwareTimer.h>
#include <SPI.h>
// Bare minimum test code: hardware timer interrupt, UART and SPI
bool ledOn = false;
HardwareTimer *tim1 = new HardwareTimer(TIM1);
void timer1ISR()
{
ledOn = !ledOn;
digitalWrite(PC13, ledOn ? HIGH:LOW);
Serial.print("LED state: "); Serial.println(ledOn);
}
void setup() {
pinMode(PC13,OUTPUT);
Serial.begin(9600);
tim1->setOverflow(1000000, MICROSEC_FORMAT);
tim1->attachInterrupt(timer1ISR);
tim1->refresh();
tim1->resume();
//SPI.begin(); // Problematic SPI.begin() call
}
void loop() {
}
With the build flags as follows:
[env:genericSTM32F411CE]
platform = ststm32
board = genericSTM32F411CE
framework = arduino
debug_tool = stlink
upload_protocol = stlink
build_flags =
-D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
-D USBCON
monitor_dtr = 1
With SPI.begin()
commented out, I get a COM port in the device manager, and I can see the serial transmissions from the board, no problem.
But if I uncomment the one call to SPI.begin()
, the COM port no longer enumerates, and I get a “USB device not recognized” error:
Is there perhaps something really simple I’m missing?