在MC9S08DZ60的MCU上,使用边沿对齐PWM输出PWM波形,主程序中会随时改变其周期(TPMxMODH:TPMxMODL), void setting_period_tpm1(unsigned int period) { unsigned int temp;
temp = period; TPM1MODH = (unsigned char)(temp >> 8); TPM1MODL = (unsigned char)temp; temp = (temp >> 0x01); TPM1C0VH = (unsigned char)(temp >> 8); TPM1C0VL = (unsigned char)temp; } 有时候会出现周期并没有立即改变,而是计数器先计数到最大值(0xFFFF)之后,周期才会改变,请问要怎么操作才能立即改变PWM的周期呢?先谢谢各位; |