Arduino 如何对STM32 DC-AC电源逆变器代码进行编码?

Arduino 如何对STM32 DC-AC电源逆变器代码进行编码?,arduino,stm32,nano,Arduino,Stm32,Nano,我有一个交流电源逆变器,使用带有中央标签的变压器。MOSFET由arduino Nano控制,在P&F上使用PWM,在timer0@31khz上使用正确模式,因为timer1正在做其他事情 输出信号具有死区时间,以避免两个MOSFET同时工作 我的问题是如何使用maple core编写相同的代码。。。特别是HardwareTimer库 以下是nano的代码函数: void SetPowerFr(){ TCCR0A = 0; //reset the register TCCR0B = 0; /

我有一个交流电源逆变器,使用带有中央标签的变压器。MOSFET由arduino Nano控制,在P&F上使用PWM,在timer0@31khz上使用正确模式,因为timer1正在做其他事情

输出信号具有死区时间,以避免两个MOSFET同时工作

我的问题是如何使用maple core编写相同的代码。。。特别是HardwareTimer库

以下是nano的代码函数:

void SetPowerFr(){
TCCR0A = 0;  //reset the register
TCCR0B = 0;  //reset the register

TCCR0A = _BV(COM0A1) | _BV(COM0B1) | _BV(WGM00);//Phase-correct
TCCR0B = (TCCR0B & 0b11111000) | 0x01;//Prescaler
TCCR0A = (TCCR0A & 0x0F) | 0xB0 ; // invert Pin B

OCR0B = 255; //it is inverted!!!

CiclosReloj = round(Crystal*1000000.0/(2.0*maxPowerFr));
currPowerFr = Crystal*1000000.0/(2.0*CiclosReloj);
}

void SetPowerDC() {//duty control set
//Positive duration (Duty cycle)
CiclosPos = round(CiclosReloj * (currPowerDC/(200.0+PowerSafe)));
}

void PowerOn(){
//ICR1 = CiclosReloj; //if timer1 is used
OCR0A = CiclosPos;  //Positive duration (Duty cycle)
OCR0B = CiclosReloj-CiclosPos; //Note: IRC1=OCR1A+OCR1B.
}

void PowerOff(){
//ICR1 = 0;//if timer1 is used
OCR0A = 0;
OCR0B = 255;//it is inverted!!!
}
以下是信号的视频: