Thanks for response
It is stm32f103, Arduino IDE.
This is a program for phase shifter of two generators 12kHz, I am opsering shaking pulses on oscilloscope.
Without <delay(100);> the shifting is very fast so it is hard to get required shift.
HardwareTimer pwmtimer1(1);
HardwareTimer pwmtimer4(4);
#include <LiquidCrystal.h>
LiquidCrystal lcd(PA0, PA1, PA2, PA3, PA4, PA5);
int i;
int ovfi;
void setup() {
pinMode(PA8, PWM); //Rx
pinMode(PB7, PWM); //Tx
pinMode(PB6, INPUT_PULLDOWN);
pinMode(PB9, INPUT_PULLDOWN);
lcd.begin(16, 2);
Serial.begin(9600);
// noInterrupts() ;
}
void loop()
{
ovfi = 10000 - i;
noInterrupts() ;
/////////////////////////////////////////////
pwmtimer1.pause();
pwmtimer1.setPrescaleFactor(1);
pwmtimer1.setOverflow(5760 - 1);
pwmtimer1.setCompare(TIMER_CH1, 2880);
pwmtimer1.refresh();
pwmtimer1.resume();
delayMicroseconds(i);
pwmtimer4.pause();
pwmtimer4.setPrescaleFactor(1);
pwmtimer4.setOverflow(5760 - 1);
pwmtimer4.setCompare(TIMER_CH2, 2880);
pwmtimer4.refresh();
pwmtimer4.resume();
///////////////////////////////////////////////////
if (digitalRead(PB9) == HIGH)
{
if (i < 6000)
// if (i < 25)
{
i++;//if pin PB3 is pressed and the duty ratio value is less than 255
analogWrite(PB0, i); // analogWrite values from 0 to 255
//delay(100);
}
}
if (digitalRead(PB6) == HIGH)
{
if (i > 0)
{
i--;// if pin PB5 is pressed and the duty ratio value is greater than 0
analogWrite(PB0, i); // analogWrite values from 0 to 255
//delay(100);
}
}
lcd.setCursor(0, 1);
lcd.println(i);
}
It is hard to see on picture but on scope it is obvious shaking, the probes are directly on the pins of stm32f103, I am very positive this is no probe issue. Post #11
By pressing the buttons the shadow pulses are shifting at 180 deg they in line with main pulses.