Change The PWM Frequnez (~31300HZ) // Arduino Nano 33 BLE

Hello, everyone. I want to drive an electric scooter and before that I used an Arduino Uno. Now an Arduino Nano 33 BLE is to be used. The problem with the whole thing is that I am showing an error when compiling de code on the Arduino Nano 33 BLE. The following is displayed: 'TCCR2B' was not declared in this scope

This is the Code:

// Pinbelegung, Nutzung der define Direktive #define routPin A0 #define yAccPin A1 #define xAccPin A2 #define PotentioPin A5 #define drehrichtungMotorLinks 6 #define drehrichtungMotorRechts 7 #define drehgeschwindigkeitMotorLinks 9 #define drehgeschwindigkeitMotorRechts 10 // Berechnungsvariablen für die Neigungswinkel (Zur Speicherung von Zwischenwerten und Endergebnissen) double gyroMesswert; double gyroNeigungswinkelNeu; double gefilterterNeigungswinkel = 0; double beschlNeigungswinkel; double beschlMesswertX; double beschlMesswertY; double radZuGradmass; double beschlUmrechnung; double gyroUmrechnung; int    potentio; // Konstanten const double pi = 3.14159;                  // Kreiszahl Pi const double k = 0.95;                      // Filterkonstante const double deltaT = 0.011;                // Wird für alle Zeitdifferenzen eingesetzt. Abhängig vom eingestellten delay, ca 1ms für Programmausführung // Sensorboardvariablen double beschlSpannung = 5.0; double gyroSpannung = 5.0; double gyroSpannungBeiRuhelage = 2.47800; double beschlSpannungBeiRuheLageX = 2.421875; double beschlSpannungBeiRuheLageY = 2.463340; double beschlSensitivitaet = 0.312; double gyroSensitivitaet = 0.015; double t1,t2,td; // Berechnungsvariablen für die Regelung double pWert; double dWert; double iWert= 0; double e = 0; double esum; double ealt; double delta; double digitaleStellgroesse = 0; double pid; // Regelparameter double kp = 9.0; double ki = 1.0; double kd = 1.0; //********************************************************************************************************************** void setup(){     Serial.begin(9600);   TCCR2B = TCCR2B & 0b11111000 | 0x01;        // Timer 2 zu 31300HZ. Timer 2 kontrolliert  die Pins 9 und 10   pinMode(drehrichtungMotorLinks, OUTPUT);    // Drehrichtung des linken Motors vorgegeben   pinMode(drehrichtungMotorRechts, OUTPUT);    // Drehrichtung des rechten Motors vorgegeben     radZuGradmass = 180.0/pi;    beschlUmrechnung = beschlSpannung/1023;    gyroUmrechnung = gyroSpannung/1023; }

The rest of the part consists only of angle calculations.

I just want to set a timer to increase the frequency. Since I ve noticed that it is not possible with the Arduino Nano 33 BLE , I build your help. Rewrite the part for the Arduino nano 33 ble. Only one timer is needed.

TCCR2B = TCCR2B & 0b11111000 | 0x01;

Tag » Arduino Nano 33 Ble Pwm Frequency