Open
Description
Hi .
I found a very weird bug is FOC library with Teensy 3.2.
This bug is not present compiling on Arduino Uno, so this is a teensy issue, compiling through Arduino
MagneticSensorSPI sensor = MagneticSensorSPI(AS5048_SPI, 10);
void setup() {
// monitoring port
Serial.begin(115200);
Serial.print("SPI MODE ARDUINO = ");
Serial.println(sensor.spi_mode);
As declaring 'sensor' as a global variable, sensor.spi_mode = SPI_MODE0 while the config for AS5048 expect spi_mode to be SPI_MODE1.
Now, if i declare sensor inside setup()
void setup() {
MagneticSensorSPI sensor = MagneticSensorSPI(AS5048_SPI, 10);
// monitoring port
Serial.begin(115200);
Serial.print("SPI MODE ARDUINO = ");
Serial.println(sensor.spi_mode);
sensor.spi_mode became what it should be = SPI_MODE1
As a result, spi_mode is wrong when sensor is declared as a global variable, that make the magnetic sensor impossible to use with teensy