Hello
Core : STM32 MCU based board by STMicro v2.2.0
Boards : bluepill copy with original STM32F103T8C6, Blackpill F411CEU, STM32F030T8C6 board
I'm trying to drive servo with the STM32_ISR_Servo librairy.
As i was having no result at all, i simply copy/paste the example code for mutiple servo that's here and only changed the SERVO_PIN_# definition to try every pins.
On STM32F103 and STM32F030, none of them work.
On the blackpill with STM32F411, the pins PC14, PC15 and PC16 only works (there's no PC# pins on the 2 other boards).
Here's the full code :
#if !( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \
defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \
defined(STM32WB) || defined(STM32MP1) || defined(STM32L5))
#error This code is designed to run on STM32F/L/H/G/WB/MP1 platform! Please check your Tools->Board setting.
#endif
#define TIMER_INTERRUPT_DEBUG 0
#define ISR_SERVO_DEBUG 1
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include "STM32_ISR_Servo.h"
// Default is TIMER_SERVO (TIM7 for many boards)
#define USE_STM32_TIMER_NO TIMER_SERVO
// Published values for SG90 servos; adjust if needed
#define MIN_MICROS 800 //544
#define MAX_MICROS 2450
#define SERVO_PIN_1 PC14
#define SERVO_PIN_2 PC13
#define SERVO_PIN_3 PC15
#define SERVO_PIN_4 A0
#define SERVO_PIN_5 PB1
#define SERVO_PIN_6 A8
typedef struct
{
int servoIndex;
uint8_t servoPin;
} ISR_servo_t;
#if ( defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32L5) )
#define NUM_SERVOS 3
ISR_servo_t ISR_servo[NUM_SERVOS] =
{
{ -1, SERVO_PIN_1 }, { -1, SERVO_PIN_2 }, { -1, SERVO_PIN_3 }
};
#else
#define NUM_SERVOS 6
ISR_servo_t ISR_servo[NUM_SERVOS] =
{
{ -1, SERVO_PIN_1 }, { -1, SERVO_PIN_2 }, { -1, SERVO_PIN_3 }, { -1, SERVO_PIN_4 }, { -1, SERVO_PIN_5 }, { -1, SERVO_PIN_6 }
};
#endif
void setup()
{
Serial.begin(115200);
while (!Serial);
delay(200);
Serial.print(F("\nStarting STM32_MultipleServos on ")); Serial.println(BOARD_NAME);
Serial.println(STM32_ISR_SERVO_VERSION);
//Select STM32 timer USE_STM32_TIMER_NO
STM32_ISR_Servos.useTimer(USE_STM32_TIMER_NO);
for (int index = 0; index < NUM_SERVOS; index++)
{
ISR_servo[index].servoIndex = STM32_ISR_Servos.setupServo(ISR_servo[index].servoPin, MIN_MICROS, MAX_MICROS);
if (ISR_servo[index].servoIndex != -1)
{
Serial.print(F("Setup OK Servo index = ")); Serial.println(ISR_servo[index].servoIndex);
}
else
{
Serial.print(F("Setup Failed Servo index = ")); Serial.println(ISR_servo[index].servoIndex);
}
}
}
void loop()
{
int position; // position in degrees
for (position = 0; position <= 180; position += 5)
{
// goes from 0 degrees to 180 degrees
// in steps of 1 degree
for (int index = 0; index < NUM_SERVOS; index++)
{
STM32_ISR_Servos.setPosition(ISR_servo[index].servoIndex, (position + index * (180 / NUM_SERVOS)) % 180 );
}
// waits 1s for the servo to reach the position
delay(200);
}
for (position = 180; position >= 0; position -= 5)
{
// goes from 0 degrees to 180 degrees
// in steps of 1 degree
for (int index = 0; index < NUM_SERVOS; index++)
{
STM32_ISR_Servos.setPosition(ISR_servo[index].servoIndex, (position + index * (180 / NUM_SERVOS)) % 180);
}
// waits 1s for the servo to reach the position
delay(200);
}
delay(200);
}
Note that on this board, the serial link doesn't work so i can't see debugging infos
Any help to understand would be great !