Question
How to covert the code according to STM32CUBEIDE
I have Arduino program how covert it to STM32CUBEIDE suggest me any websites or channel for applying logics and change the program to it tell me any forum where i could learn the logic and apply it to real world applications
Here i have given the code below
#define HIGH_SIDE_A 9 // High-side MOSFET on side A
#define HIGH_SIDE_B 11 // High-side MOSFET on side B
#define FREQUENCY 60// 60 Hz
#define DUTY_CYCLE 100 // 100% duty cycle
int dt=8333.33; //dead-time
unsigned long period;
unsigned long highStateDuration;
unsigned long lowStateDuration;
unsigned long lastChangeTime;
bool isHighState = true;
void setup() {
pinMode(HIGH_SIDE_A, OUTPUT);
pinMode(HIGH_SIDE_B, OUTPUT);
period = 1000000 / FREQUENCY; // Period in microseconds
highStateDuration = (period * DUTY_CYCLE) / 100; // High state duration
lowStateDuration = highStateDuration; // Low state duration is equal to high state duration
}
void loop() {
unsigned long currentTime = micros();
if (isHighState && currentTime - lastChangeTime >= highStateDuration) {
// Switch to Low State
digitalWrite(HIGH_SIDE_A, LOW);
delayMicroseconds((period * dt) / 100); // 10% of period as dead time
digitalWrite(HIGH_SIDE_B, HIGH);
lastChangeTime = currentTime;
isHighState = false;
} else if (!isHighState && currentTime - lastChangeTime >= lowStateDuration) {
// Switch to High State
digitalWrite(HIGH_SIDE_B, LOW);
delayMicroseconds((period * dt) / 100); // 10% of period as dead time
digitalWrite(HIGH_SIDE_A, HIGH);
lastChangeTime = currentTime;
isHighState=true;
}
}