我用PC3/PC4/PC6/PC7来做产生2对互补PWM,PC3/PC6/PC7周期、死区都正常,但是PC4在我期望的PWM上还会叠加一个33kHz的方波,我设置的周期是2kHz。我一直怀疑是时钟输出(CCO)的串扰。请各位大侠帮忙看看是怎么回事。一下是初始化代码: void InitSystem(void) { CLK->CKDIVR &= (u8)~(CLK_CKDIVR_CPUDIV); // fcpu= fmaster (CPUDIV= 0) CLK->CKDIVR &= (u8)~(CLK_CKDIVR_HSIDIV); // fhsi= fhsirc (HSIDIV= 0) CLK->ICKR |= CLK_ICKR_HSIEN; //时能内部始 while((CLK->ICKR&0x02) == 0) {}; //等待内部始终就绪 CLK->CCOR = 0x00; //禁止CCO时钟输出 } void InitTimer1(void) { CLK->PCKENR1 |= CLK_PCKENR1_TIM1; //TIM1 Clock Enable TIM1->CR1 = 0x40;//递增递减计数中央对齐,只在递增中断。 TIM1->SR1 = 0x00;//清除中断标志位 TIM1->SR2 = 0x00; TIM1->CCMR1 = 0x68; TIM1->CCMR2 = 0x68; TIM1->CCER1 = 0xFF;// iP高电平,iN低电平 TIM1->PSCRH = 0; TIM1->PSCRL = 0; //16MHz时钟 TIM1->ARRH = (u8)(((PwmPeriod - 1) >> 8)&0xff); // init pulse period - auto reload register TIM1->ARRL = (u8)((PwmPeriod - 1)&0xff); TIM1->CCR1H = 0; TIM1->CCR1L = 98; TIM1->CCR2H = 0; TIM1->CCR2L = 95; TIM1->DTR = 60; TIM1->IER |= TIM1_IER_UIE ; //不用刹车中断,硬件没有接允许更新中断 中断号11 TIM1->CR1 |= TIM1_CR1_URS | TIM1_CR1_CEN; // enable timer; TIM1->BKR = 0x80; TIM1->EGR |= 0x01; } |
é项åé ç½®
求一个STM8S207例程
初次接触STM8,请问在STVD中,为什么这个Struct会报错
STMS005K6T6 如何采集内部参考电压。
stm8s003 adc中断和通道切换的问题
adc施密特触发器stm8
stm8l051f3 TSSOP20 封装,待机模式下,2天后,电流突然增加到140UA
STM8S用STVP烧录怎么加密?
如何使用ST官网例程_LIN总线通讯_STM8AF
STM8 LIN
IAR代码编辑太费劲了,想问一下有没有好的方法,试了VScode但是头文件老是报错,调了很久也没调好,想换个方法了。
{
CLK->CKDIVR &= (u8)~(CLK_CKDIVR_CPUDIV); //fcpu= fmaster (CPUDIV= 0)
CLK->CKDIVR &= (u8)~(CLK_CKDIVR_HSIDIV); //fhsi= fhsirc (HSIDIV= 0)
CLK->ICKR |= CLK_ICKR_HSIEN; //时能内部始
while((CLK->ICKR&0x02) == 0) {}; //等待内部始终就绪
CLK->CCOR = 0x00; //禁止CCO时钟输出
}
void InitTimer1(void)
{
CLK->PCKENR1 |= CLK_PCKENR1_TIM1;//TIM1 Clock Enable
TIM1->CR1 = 0x40;//递增递减计数中央对齐,只在递增中断。
TIM1->SR1 = 0x00;//清除中断标志位
TIM1->SR2 = 0x00;
TIM1->CCMR1 = 0x68;
TIM1->CCMR2 = 0x68;
TIM1->CCER1 = 0xFF;// iP高电平,iN低电平
TIM1->PSCRH = 0;
TIM1->PSCRL = 0; //16MHz时钟
TIM1->ARRH = (u8)(((PwmPeriod - 1) >>8)&0xff); // init pulseperiod - auto reload register
TIM1->ARRL = (u8)((PwmPeriod - 1)&0xff);
TIM1->CCR1H = 0;
TIM1->CCR1L = 98;
TIM1->CCR2H = 0;
TIM1->CCR2L = 95;
TIM1->DTR = 60;
TIM1->IER |= TIM1_IER_UIE ; //不用刹车中断,硬件没有接允许更新中断 中断号11
TIM1->CR1 |= TIM1_CR1_URS | TIM1_CR1_CEN; //enable timer;
TIM1->BKR = 0x80;
TIM1->EGR |= 0x01;
}