Table of Contents

Stm32F103PWMTest

Übersicht

Idee

Weiterführung

Aufgaben STM32F103C8T6

220331: Stm32F103PwmTest

220331: Stm32F103: Aufbau Timer / Channel

//
//------------------------------------------------------------
const int PIN_PWM_A24 = PB11; // ok
const int PIN_PWM_A23 = PB10; // ok
const int PIN_PWM_A34 = PB1;  // ok
const int PIN_PWM_A33 = PB0;  // ok
const int PIN_PWM_A32 = PA7;  // interference PB0/PB1
const int PIN_PWM_A31 = PA6;  // ok
//
const int PIN_PWM_B24 = PA3; // Uart
const int PIN_PWM_B23 = PA2; // Uart
const int PIN_PWM_B22 = PA1; // interference PB10
//
const int PIN_PWM_C11N = PB13; // interference PB0/PB1
const int PIN_PWM_C12N = PB14; // interference PB0/PB1
const int PIN_PWM_C13N = PB15; // interference PB0/PB1
const int PIN_PWM_C11 = PA8;   // interference PB0/PB1
const int PIN_PWM_C12 = PA9;   // interference PB0/PB1
const int PIN_PWM_C13 = PA10;  // interference PB0/PB1
const int PIN_PWM_C14 = PA11;  // interference PB0/PB1
//
const int PIN_PWM_D21 = PA15;  // interference PB0/PB1
const int PIN_PWM_D22 = PB3;   // interference PB0/PB1
const int PIN_PWM_D23 = PB4;   // ok
const int PIN_PWM_D24 = PB5;   // ok
//------------------------------------------------------------
// Pwm
CPulseWidthModulator ActorA(PIN_PWM_A24);
CPulseWidthModulator ActorB(PIN_PWM_A23);
CPulseWidthModulator ActorC(PIN_PWM_A34);
CPulseWidthModulator ActorD(PIN_PWM_A33);
CPulseWidthModulator ActorE(PIN_PWM_D23);
CPulseWidthModulator ActorF(PIN_PWM_D24);
//
for (int I = 0; I < 100; I += 1)
{ // Motor
  int PwmActorA = min(MAX_PWMA, max(MIN_PWMA, I));
  int PwmActorB = min(MAX_PWMB, max(MIN_PWMB, 100 - I));
  int PwmActorC = min(MAX_PWMC, max(MIN_PWMC, I));
  int PwmActorD = min(MAX_PWMD, max(MIN_PWMD, 100 - I));
  int PwmActorE = min(MAX_PWMA, max(MIN_PWMA, I));
  ActorA.SetFrequencyPwm(FREQUENCY_HIGH, PwmActorA);
  ActorB.SetFrequencyPwm(FREQUENCY_HIGH, PwmActorB);
  ActorC.SetFrequencyPwm(FREQUENCY_LOW, PwmActorC);
  ActorD.SetFrequencyPwm(FREQUENCY_LOW, PwmActorD);
  ActorE.SetFrequencyPwm(FREQUENCY_HIGH, PwmActorE);
  //
  delay(100);
}
// 2kHz !!! only ONE PWM-Frequency!
void setup()
{ 
  analogWriteResolution(16);
  analogWriteFrequency(2000); // 2kHz !!! only ONE PWM-Frequency!
  analogWrite(PB11, 20000);     
  analogWrite(PB10, 40000);    
  analogWrite(PB0, 20000);     
  analogWrite(PB1, 40000);    
}

220330: Stm32F103: Aufbau Timer / Channel