setup software-pwm and use same timer to measure time.
problem: pwm frequency low.
currently i'm using an at90s2343 to measure rpm (time between pulses) and to output a PWM-Signal.
the calculation between the both values doesn't matter now.
my problem is, that my PWM frequency is too slow.
The controller is running on internal r-c oscillator with 1 MHz.
My algorithm describes as follows:
Timer prescaler = 8
timer overflow-interrupt: (tovf0)
get pwm-setpoint (8bit).
set timer value to a value that the next overflow happens at the desired time.
count up the (virtual) high-byte of timer0 on the correct condition.
change the status of the output pin.
external interupt: (int0)
get the actual timer value.
correct the timer value using the status of PWM-period (=putput pin).
get hi-byte oft timer0.
store current timer0 (lo corrected, hi) in registers old_timer(16bit) (or sram)
calculate difference between act. timer0(16bit) and old_timer(16bit)
output the difference on duration-registers (16bit)
get duration-registers (1/ rpm)
calculate PID ... etc.
put pwm_setpoint (8bit)
the timer-overflow- interrupt takes 26 clocks.
so i cannot go below 4 or above 251 with the pwm_setpoint, but this is no problem.
by the way: i code with bascom-compiler.
But both interrupt-routines are coded in assembler.
The question is: is there a possibility to speed up the frequency by a software-trick ?
(i still want to use the timer for measuring the rpm.)
kind regards and thanx for any comment