I recently started to study attiny datasheet. I need two pwm output for my projects (mainly SPMS with synchronous rectification) and I found out that analogWrite function is no longer enough. To be more precise, I need two pwm (inverted or not) with dead times inserted. After studying the datasheet, in order to get two pwm signals, non-inverted, with variable duty cycle according to the set voltage from a potentiometer, I wrote the following code, which did not work properly:
#define pwm_pin 1
#define pwm_pin_pr 4
#define pot_pin A1
int potinputval;
void setup()
{
pinMode(pwm_pin,OUTPUT);
pinMode(pwm_pin_pr,OUTPUT);
pinMode(pot_pin,INPUT);
TCCR1 = 1<<PWM1A | 1<<COM1A1 | 0<<COM1A0 | 0<<CS13 | 0<<CS12 | 1<<CS11 | 0<<CS10 | 1<<CTC1;
GTCCR = 1<<PWM1B | 1<<COM1B1 | 0<<COM1B0;
OCR1C = 127;
DTPS1 = 0<<DTPS11 | 1<<DTPS10;
DT1B = 1<<DT1BH3 | 1<<DT1BH2 | 1<<DT1BH1 | 1<<DT1BH0;
}
void loop()
{
potinputval=analogRead(pot_pin);
potinputval=map(potinputval,1023,0,127,0);
OCR1A=potinputval;
OCR1B=potinputval;
}
But what I actually get is a set of two identical pwm signals, which are quite shaky.
I added some photos of what my scope is showing.
Please add detailed answers if it is possible. I am new in Arduino and electronics.
Many thanks in advance.

