Metin:
I am away on a business trip for work, however, these are my suggestions until I get to be able to look into this on the bench:
- Please double check that you included the optional build .h file to enable the hardware serial. This is a file called
build_opt.h
which must be placed in your arduino project file directory
-D ENABLE_HWSERIAL1 -D ENABLE_HWSERIAL2 -D ENABLE_HWSERIAL3
After you do that, try hardware Serial2 again, but read the other points below first.
-
Lower your baud rate to 9600 to make sure you exclude/filter any noise in the lines.
-
Make sure your FTDI converter is set to work with 3.3V, not 5V logic.
-
Make sure your Lepton RX goes into the FTDI TX, and the TX into the RX (they must be crossed).
-
If the hardware serial still fails, here is sample code for you to try software serial, this works on any two pins. I edited the code to match the Lepton Serial pins. This will override the hardware serial and should be able to get the Serial working.
#include "SoftwareSerial.h"
#define SS_USB_RX PA15
#define SS_USB_TX PA2
// ANY OTHER SOFT SERIAL BAUD RATE WILL CHOKE
// BAUD RATE MUST BE BETWEEN 9600..38400
// ANY OTHER BAUD RATE WILL CHOKE
SoftwareSerial SoftSerialUSB(SS_USB_RX, SS_USB_TX);
void setup()
{
//set pins for Software Serial communication
SoftSerialUSB.begin(9600);
pinMode(SS_USB_RX, INPUT);
pinMode(SS_USB_TX, OUTPUT);
delay(1000);
}
void loop()
{
SoftSerialUSB.println("TEST SSERIAL_USB");
delay(100);
}
You need to include this software serial sample code in your SimpleFOC code.
Cheers,
Valentine