I use the chip is MC68HC908JK3E, select the timer's channel 1 to capture the external input square wave signal (100-250Hz) period. At the same time, according to the different period, I use timer's channel 0 output adjustable duty cycle square wave signal (20KHz). In the program, I constantly modify the TCH0H and TCH0L to change the duty cycle of the output signal. The current problems are: the capture signal cycle is not accurate, what are the reasons for this? Thank you!
Original Attachment has been moved to: code.txt.zip